mirror of
https://github.com/boostorg/lambda2.git
synced 2025-05-11 21:53:58 +00:00
Add first, second function objects. Fixes #5.
This commit is contained in:
parent
f8b3099259
commit
7c39436198
@ -32,6 +32,14 @@ struct subscript
|
||||
}
|
||||
};
|
||||
|
||||
template<int I> struct get
|
||||
{
|
||||
template<class T> decltype(auto) operator()( T&& t ) const
|
||||
{
|
||||
return std::get<I>( std::forward<T>(t) );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace lambda2_detail
|
||||
|
||||
// placeholders
|
||||
@ -65,6 +73,11 @@ BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<7> _7{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<8> _8{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_arg<9> _9{};
|
||||
|
||||
// first, second
|
||||
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<0> first{};
|
||||
BOOST_LAMBDA2_INLINE_VAR constexpr lambda2_detail::get<1> second{};
|
||||
|
||||
#undef BOOST_LAMBDA2_INLINE_VAR
|
||||
|
||||
} // namespace lambda2
|
||||
|
@ -63,6 +63,9 @@ int main()
|
||||
|
||||
BOOST_TEST_EQ( (_1->*&std::pair<int, int>::first)( x ), 1 );
|
||||
BOOST_TEST_EQ( (_1->*&std::pair<int, int>::second)( x ), 2 );
|
||||
|
||||
BOOST_TEST_EQ( (_1->*first)( x ), 1 );
|
||||
BOOST_TEST_EQ( (_1->*second)( x ), 2 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
|
Loading…
x
Reference in New Issue
Block a user