Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2005-2013 Joel de Guzman
|
Chris@16
|
3
|
Chris@16
|
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
6 ==============================================================================*/
|
Chris@16
|
7 #if !defined(BOOST_FUSION_BUILD_DEQUE_02032013_1921)
|
Chris@16
|
8 #define BOOST_FUSION_BUILD_DEQUE_02032013_1921
|
Chris@16
|
9
|
Chris@101
|
10 #include <boost/fusion/support/config.hpp>
|
Chris@16
|
11 #include <boost/fusion/iterator/equal_to.hpp>
|
Chris@16
|
12 #include <boost/fusion/iterator/next.hpp>
|
Chris@16
|
13 #include <boost/fusion/iterator/value_of.hpp>
|
Chris@16
|
14 #include <boost/fusion/iterator/deref.hpp>
|
Chris@16
|
15 #include <boost/fusion/sequence/intrinsic/begin.hpp>
|
Chris@16
|
16 #include <boost/fusion/sequence/intrinsic/end.hpp>
|
Chris@16
|
17 #include <boost/fusion/container/deque/front_extended_deque.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 namespace boost { namespace fusion { namespace detail
|
Chris@16
|
20 {
|
Chris@16
|
21 template <typename First, typename Last
|
Chris@16
|
22 , bool is_empty = result_of::equal_to<First, Last>::value>
|
Chris@16
|
23 struct build_deque;
|
Chris@16
|
24
|
Chris@16
|
25 template <typename First, typename Last>
|
Chris@16
|
26 struct build_deque<First, Last, true>
|
Chris@16
|
27 {
|
Chris@16
|
28 typedef deque<> type;
|
Chris@101
|
29 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
30 static type
|
Chris@16
|
31 call(First const&, Last const&)
|
Chris@16
|
32 {
|
Chris@16
|
33 return type();
|
Chris@16
|
34 }
|
Chris@16
|
35 };
|
Chris@16
|
36
|
Chris@16
|
37 template <typename T, typename Rest>
|
Chris@16
|
38 struct push_front_deque;
|
Chris@16
|
39
|
Chris@16
|
40 template <typename T, typename ...Rest>
|
Chris@16
|
41 struct push_front_deque<T, deque<Rest...>>
|
Chris@16
|
42 {
|
Chris@16
|
43 typedef deque<T, Rest...> type;
|
Chris@16
|
44
|
Chris@101
|
45 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
46 static type
|
Chris@16
|
47 call(T const& first, deque<Rest...> const& rest)
|
Chris@16
|
48 {
|
Chris@16
|
49 return type(front_extended_deque<deque<Rest...>, T>(rest, first));
|
Chris@16
|
50 }
|
Chris@16
|
51 };
|
Chris@16
|
52
|
Chris@16
|
53 template <typename First, typename Last>
|
Chris@16
|
54 struct build_deque<First, Last, false>
|
Chris@16
|
55 {
|
Chris@16
|
56 typedef
|
Chris@16
|
57 build_deque<typename result_of::next<First>::type, Last>
|
Chris@16
|
58 next_build_deque;
|
Chris@16
|
59
|
Chris@16
|
60 typedef push_front_deque<
|
Chris@16
|
61 typename result_of::value_of<First>::type
|
Chris@16
|
62 , typename next_build_deque::type>
|
Chris@16
|
63 push_front;
|
Chris@16
|
64
|
Chris@16
|
65 typedef typename push_front::type type;
|
Chris@16
|
66
|
Chris@101
|
67 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
68 static type
|
Chris@16
|
69 call(First const& f, Last const& l)
|
Chris@16
|
70 {
|
Chris@16
|
71 typename result_of::value_of<First>::type v = *f;
|
Chris@16
|
72 return push_front::call(
|
Chris@16
|
73 v, next_build_deque::call(fusion::next(f), l));
|
Chris@16
|
74 }
|
Chris@16
|
75 };
|
Chris@16
|
76 }}}
|
Chris@16
|
77
|
Chris@16
|
78 #endif
|