1
0
forked from boostorg/mp11

Add make_from_tuple

This commit is contained in:
Peter Dimov
2017-06-08 17:42:50 +03:00
parent 359ae25630
commit 08777edbc1
7 changed files with 353 additions and 0 deletions

View File

@@ -2695,6 +2695,24 @@ BOOST_CONSTEXPR auto tuple_apply( F && f, Tp && tp )
return detail::tuple_apply_impl( std::forward<F>(f), std::forward<Tp>(tp), Seq() );
}
// make_from_tuple
namespace detail
{
template<class T, class Tp, std::size_t... J> BOOST_CONSTEXPR T make_from_tuple_impl( Tp && tp, integer_sequence<std::size_t, J...> )
{
return T( std::get<J>(std::forward<Tp>(tp))... );
}
} // namespace detail
template<class T, class Tp,
class Seq = make_index_sequence<std::tuple_size<typename std::remove_reference<Tp>::type>::value>>
BOOST_CONSTEXPR T make_from_tuple( Tp && tp )
{
return detail::make_from_tuple_impl<T>( std::forward<Tp>(tp), Seq() );
}
// tuple_for_each
namespace detail
{