Skip to content
Snippets Groups Projects
Commit b742ef67 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

remove unused call_on_nth on tuple

parent 71232b50
No related branches found
No related tags found
No related merge requests found
......@@ -62,32 +62,6 @@ struct tuple_element < I, T && > {
 
 
 
template < unsigned I >
struct call_on_nth_helper {
template < class Result, class Tuple, class Callable >
static Result call_on_nth_fn ( Tuple && t, unsigned index, Callable callback ) {
if ( index == 0 )
return callback ( std::forward < Tuple && > ( t ).template get < ext::tuple_size < Tuple >::value - I > ( ) );
else
return call_on_nth_helper < I - 1 >::template call_on_nth_fn < Result > ( std::forward < Tuple && > ( t ), index - 1, callback );
}
};
template < >
struct call_on_nth_helper < 0 > {
template < class Result, class Tuple, class Callable >
static Result call_on_nth_fn ( Tuple &&, unsigned, Callable ) {
throw std::out_of_range ( "Not enough elements in tuple." );
}
};
template < class Result, class Tuple, class Callable >
Result call_on_nth ( Tuple && t, unsigned index, Callable callback ) {
return call_on_nth_helper < ext::tuple_size < Tuple >::value >::template call_on_nth_fn < Result > ( std::forward < Tuple && > ( t ), index, callback );
}
template < unsigned I >
struct foreach_helper {
template < class Tuple, class Callable >
......
......@@ -6,8 +6,6 @@ TEST_CASE ( "PtrTuple", "[unit][std][container]" ) {
SECTION ( "Test call on nth" ) {
ext::ptr_tuple < int, int, int, int, int > t = ext::make_ptr_tuple ( 1, 2, 3, 4, 5 );
 
CHECK ( ext::call_on_nth < int > ( t, 1, [] ( int i ) { return i; } ) == 2 );
std::stringstream ss;
ss << t;
CAPTURE ( ss.str ( ) );
......
......@@ -6,8 +6,6 @@ TEST_CASE ( "Tuple", "[unit][std][container]" ) {
SECTION ( "Test call on nth" ) {
ext::tuple < int, int, int, int, int > t = ext::make_tuple ( 1, 2, 3, 4, 5 );
 
CHECK ( ext::call_on_nth < int > ( t, 1, [] ( int i ) { return i; } ) == 2 );
std::stringstream ss;
ss << t;
CAPTURE ( ss.str ( ) );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment