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_MAP_02042013_1448)
|
Chris@16
|
8 #define BOOST_FUSION_BUILD_MAP_02042013_1448
|
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/map/map.hpp>
|
Chris@16
|
18 #include <boost/fusion/algorithm/transformation/push_front.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace fusion { namespace detail
|
Chris@16
|
21 {
|
Chris@101
|
22 template <typename First, typename Last, bool is_assoc
|
Chris@101
|
23 , bool is_empty = result_of::equal_to<First, Last>::value
|
Chris@101
|
24 >
|
Chris@16
|
25 struct build_map;
|
Chris@16
|
26
|
Chris@101
|
27 template <typename First, typename Last, bool is_assoc>
|
Chris@101
|
28 struct build_map<First, Last, is_assoc, true>
|
Chris@16
|
29 {
|
Chris@16
|
30 typedef map<> type;
|
Chris@101
|
31 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
32 static type
|
Chris@16
|
33 call(First const&, Last const&)
|
Chris@16
|
34 {
|
Chris@16
|
35 return type();
|
Chris@16
|
36 }
|
Chris@16
|
37 };
|
Chris@16
|
38
|
Chris@16
|
39 template <typename T, typename Rest>
|
Chris@16
|
40 struct push_front_map;
|
Chris@16
|
41
|
Chris@16
|
42 template <typename T, typename ...Rest>
|
Chris@16
|
43 struct push_front_map<T, map<Rest...>>
|
Chris@16
|
44 {
|
Chris@16
|
45 typedef map<T, Rest...> type;
|
Chris@16
|
46
|
Chris@101
|
47 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
48 static type
|
Chris@16
|
49 call(T const& first, map<Rest...> const& rest)
|
Chris@16
|
50 {
|
Chris@16
|
51 return type(push_front(rest, first));
|
Chris@16
|
52 }
|
Chris@16
|
53 };
|
Chris@16
|
54
|
Chris@101
|
55 template <typename First, typename Last, bool is_assoc>
|
Chris@101
|
56 struct build_map<First, Last, is_assoc, false>
|
Chris@16
|
57 {
|
Chris@16
|
58 typedef
|
Chris@101
|
59 build_map<typename result_of::next<First>::type, Last, is_assoc>
|
Chris@16
|
60 next_build_map;
|
Chris@16
|
61
|
Chris@16
|
62 typedef push_front_map<
|
Chris@101
|
63 typename pair_from<First, is_assoc>::type
|
Chris@16
|
64 , typename next_build_map::type>
|
Chris@16
|
65 push_front;
|
Chris@16
|
66
|
Chris@16
|
67 typedef typename push_front::type type;
|
Chris@16
|
68
|
Chris@101
|
69 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
|
Chris@16
|
70 static type
|
Chris@16
|
71 call(First const& f, Last const& l)
|
Chris@16
|
72 {
|
Chris@16
|
73 return push_front::call(
|
Chris@101
|
74 pair_from<First, is_assoc>::call(f)
|
Chris@101
|
75 , next_build_map::call(fusion::next(f), l));
|
Chris@16
|
76 }
|
Chris@16
|
77 };
|
Chris@16
|
78 }}}
|
Chris@16
|
79
|
Chris@16
|
80 #endif
|