mirror of
https://github.com/boostorg/mp11.git
synced 2025-12-04 07:49:20 +01:00
Add tuple_apply
This commit is contained in:
@@ -38,6 +38,26 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::tuple<int, short, char> const tp{ 1, 2, 3 };
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 123 );
|
||||
}
|
||||
}
|
||||
|
||||
#if defined( __clang_major__ ) && __clang_major__ == 3 && __clang_minor__ < 8
|
||||
#else
|
||||
|
||||
@@ -73,6 +93,26 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::pair<int, short> const tp{ 1, 2 };
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 12 );
|
||||
}
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 12 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::array<int, 3> tp{{ 1, 2, 3 }};
|
||||
|
||||
@@ -93,6 +133,26 @@ int main()
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::array<int, 3> const tp{{ 1, 2, 3 }};
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( tp, [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 123 );
|
||||
}
|
||||
|
||||
{
|
||||
int s = 0;
|
||||
|
||||
tuple_for_each( std::move(tp), [&]( int x ){ s = s * 10 + x; } );
|
||||
|
||||
BOOST_TEST_EQ( s, 123 );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::tuple<> tp;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user