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>
18#if defined(BOOST_NO_CXX17_STD_INVOKE)
19#include <boost/context/detail/invoke.hpp>
20#endif
21#include <boost/context/detail/index_sequence.hpp>
22
23#ifdef BOOST_HAS_ABI_HEADERS
24# include BOOST_ABI_PREFIX
25#endif
26
27#if defined(BOOST_MSVC)
28# pragma warning(push)
29# pragma warning(disable: 4100)
30#endif
31
32namespace boost {
33namespace context {
34namespace detail {
35
36template< typename Fn, typename Tpl, std::size_t ... I >
37auto
38apply_impl( Fn && fn, Tpl && tpl, index_sequence< I ... >)
39#if defined(BOOST_NO_CXX17_STD_INVOKE)
40 -> decltype( boost::context::detail::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ) )
41#else
42 -> decltype( std::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... ) )
43#endif
44{
45#if defined(BOOST_NO_CXX17_STD_INVOKE)
46 return boost::context::detail::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... );
47#else
48 return std::invoke( std::forward< Fn >( fn), std::get< I >( std::forward< Tpl >( tpl) ) ... );
49#endif
50}
51
52template< typename Fn, typename Tpl >
53auto
54apply( 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
66#if defined(BOOST_MSVC)
67# pragma warning(pop)
68#endif
69
70#ifdef BOOST_HAS_ABI_HEADERS
71#include BOOST_ABI_SUFFIX
72#endif
73
74#endif // BOOST_CONTEXT_DETAIL_APPLY_H
75

source code of boost/libs/context/include/boost/context/detail/apply.hpp