]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | |
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) | |
6 | ||
7 | #ifndef BOOST_CONTEXT_DETAIL_APPLY_H | |
8 | #define BOOST_CONTEXT_DETAIL_APPLY_H | |
9 | ||
10 | #include <functional> | |
11 | #include <tuple> | |
12 | #include <type_traits> | |
13 | #include <utility> | |
14 | ||
15 | #include <boost/config.hpp> | |
16 | ||
17 | #include <boost/context/detail/config.hpp> | |
b32b8144 | 18 | #if defined(BOOST_NO_CXX17_STD_INVOKE) |
7c673cae | 19 | #include <boost/context/detail/invoke.hpp> |
b32b8144 | 20 | #endif |
7c673cae FG |
21 | #include <boost/context/detail/index_sequence.hpp> |
22 | ||
23 | #ifdef BOOST_HAS_ABI_HEADERS | |
24 | # include BOOST_ABI_PREFIX | |
25 | #endif | |
26 | ||
b32b8144 FG |
27 | #if defined(BOOST_MSVC) |
28 | # pragma warning(push) | |
29 | # pragma warning(disable: 4100) | |
30 | #endif | |
31 | ||
7c673cae FG |
32 | namespace boost { |
33 | namespace context { | |
34 | namespace detail { | |
35 | ||
36 | template< typename Fn, typename Tpl, std::size_t ... I > | |
37 | auto | |
38 | apply_impl( Fn && fn, Tpl && tpl, index_sequence< I ... >) | |
b32b8144 | 39 | #if defined(BOOST_NO_CXX17_STD_INVOKE) |
11fdf7f2 | 40 | -> decltype( boost::context::detail::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ) ) |
b32b8144 FG |
41 | #else |
42 | -> decltype( std::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ) ) | |
43 | #endif | |
7c673cae | 44 | { |
b32b8144 | 45 | #if defined(BOOST_NO_CXX17_STD_INVOKE) |
11fdf7f2 | 46 | return boost::context::detail::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ); |
b32b8144 FG |
47 | #else |
48 | return std::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ); | |
49 | #endif | |
7c673cae FG |
50 | } |
51 | ||
52 | template< typename Fn, typename Tpl > | |
53 | auto | |
54 | apply( Fn && fn, Tpl && tpl) | |
55 | -> decltype( apply_impl( std::forward< Fn >( fn), | |
56 | std::forward< Tpl >( tpl), | |
57 | make_index_sequence< std::tuple_size< typename std::decay< Tpl >::type >::value >{}) ) | |
58 | { | |
59 | return apply_impl( std::forward< Fn >( fn), | |
60 | std::forward< Tpl >( tpl), | |
61 | make_index_sequence< std::tuple_size< typename std::decay< Tpl >::type >::value >{}); | |
62 | } | |
63 | ||
64 | }}} | |
65 | ||
b32b8144 FG |
66 | #if defined(BOOST_MSVC) |
67 | # pragma warning(pop) | |
68 | #endif | |
69 | ||
7c673cae FG |
70 | #ifdef BOOST_HAS_ABI_HEADERS |
71 | #include BOOST_ABI_SUFFIX | |
72 | #endif | |
73 | ||
74 | #endif // BOOST_CONTEXT_DETAIL_APPLY_H |