2 // Copyright Oliver Kowalke 2014.
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_CONTEXT_DETAIL_APPLY_H
8 #define BOOST_CONTEXT_DETAIL_APPLY_H
12 #include <type_traits>
15 #include <boost/config.hpp>
17 #include <boost/context/detail/config.hpp>
18 #include <boost/context/detail/invoke.hpp>
19 #include <boost/context/detail/index_sequence.hpp>
21 #ifdef BOOST_HAS_ABI_HEADERS
22 # include BOOST_ABI_PREFIX
29 template< typename Fn, typename Tpl, std::size_t ... I >
31 apply_impl( Fn && fn, Tpl && tpl, index_sequence< I ... >)
32 -> decltype( invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ) )
34 return invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... );
37 template< typename Fn, typename Tpl >
39 apply( Fn && fn, Tpl && tpl)
40 -> decltype( apply_impl( std::forward< Fn >( fn),
41 std::forward< Tpl >( tpl),
42 make_index_sequence< std::tuple_size< typename std::decay< Tpl >::type >::value >{}) )
44 return apply_impl( std::forward< Fn >( fn),
45 std::forward< Tpl >( tpl),
46 make_index_sequence< std::tuple_size< typename std::decay< Tpl >::type >::value >{});
51 #ifdef BOOST_HAS_ABI_HEADERS
52 #include BOOST_ABI_SUFFIX
55 #endif // BOOST_CONTEXT_DETAIL_APPLY_H