]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2014 Kohei Takahashi | |
3 | ||
4 | Distributed under the Boost Software License, Version 1.0. (See accompanying | |
5 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
6 | ==============================================================================*/ | |
7 | #if !defined(BOOST_FUSION_BUILD_STD_TUPLE_05292014_0100) | |
8 | #define BOOST_FUSION_BUILD_STD_TUPLE_05292014_0100 | |
9 | ||
10 | #include <boost/fusion/support/config.hpp> | |
11 | #include <boost/fusion/support/detail/index_sequence.hpp> | |
12 | #include <boost/fusion/iterator/equal_to.hpp> | |
13 | #include <boost/fusion/iterator/next.hpp> | |
14 | #include <boost/fusion/iterator/value_of.hpp> | |
15 | #include <boost/fusion/iterator/deref.hpp> | |
16 | #include <tuple> | |
17 | #include <cstddef> | |
18 | ||
19 | namespace boost { namespace fusion { namespace detail | |
20 | { | |
21 | template <typename First, typename Last, | |
22 | bool is_empty = result_of::equal_to<First, Last>::value> | |
23 | struct build_std_tuple; | |
24 | ||
25 | template <typename First, typename Last> | |
26 | struct build_std_tuple<First, Last, true> | |
27 | { | |
28 | typedef std::tuple<> type; | |
29 | ||
30 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
31 | static type | |
32 | call(First const&, Last const&) | |
33 | { | |
34 | return type(); | |
35 | } | |
36 | }; | |
37 | ||
38 | template <typename T, typename Rest> | |
39 | struct push_front_std_tuple; | |
40 | ||
41 | template <typename T, typename ...Rest> | |
42 | struct push_front_std_tuple<T, std::tuple<Rest...> > | |
43 | { | |
44 | typedef std::tuple<T, Rest...> type; | |
45 | ||
46 | template <std::size_t ...I> | |
47 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
48 | static type | |
49 | indexed_call(T const& first, std::tuple<Rest...> const& rest, index_sequence<I...>) | |
50 | { | |
51 | return type(first, std::get<I>(rest)...); | |
52 | } | |
53 | ||
54 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
55 | static type | |
56 | call(T const& first, std::tuple<Rest...> const& rest) | |
57 | { | |
58 | typedef typename make_index_sequence<sizeof...(Rest)>::type gen; | |
59 | return indexed_call(first, rest, gen()); | |
60 | } | |
61 | }; | |
62 | ||
63 | template <typename First, typename Last> | |
64 | struct build_std_tuple<First, Last, false> | |
65 | { | |
66 | typedef | |
67 | build_std_tuple<typename result_of::next<First>::type, Last> | |
68 | next_build_std_tuple; | |
69 | ||
70 | typedef push_front_std_tuple< | |
71 | typename result_of::value_of<First>::type | |
72 | , typename next_build_std_tuple::type> | |
73 | push_front; | |
74 | ||
75 | typedef typename push_front::type type; | |
76 | ||
77 | BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED | |
78 | static type | |
79 | call(First const& f, Last const& l) | |
80 | { | |
81 | typename result_of::value_of<First>::type v = *f; | |
82 | return push_front::call( | |
83 | v, next_build_std_tuple::call(fusion::next(f), l)); | |
84 | } | |
85 | }; | |
86 | }}} | |
87 | ||
88 | #endif |