1 /*=============================================================================
2 Copyright (c) 2005-2013 Joel de Guzman
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_MAP_02042013_1448)
8 #define BOOST_FUSION_BUILD_MAP_02042013_1448
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/iterator/equal_to.hpp>
12 #include <boost/fusion/iterator/next.hpp>
13 #include <boost/fusion/iterator/value_of.hpp>
14 #include <boost/fusion/iterator/deref.hpp>
15 #include <boost/fusion/sequence/intrinsic/begin.hpp>
16 #include <boost/fusion/sequence/intrinsic/end.hpp>
17 #include <boost/fusion/container/map/map.hpp>
18 #include <boost/fusion/algorithm/transformation/push_front.hpp>
20 namespace boost { namespace fusion { namespace detail
22 template <typename First, typename Last, bool is_assoc
23 , bool is_empty = result_of::equal_to<First, Last>::value
27 template <typename First, typename Last, bool is_assoc>
28 struct build_map<First, Last, is_assoc, true>
31 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
33 call(First const&, Last const&)
39 template <typename T, typename Rest>
40 struct push_front_map;
42 template <typename T, typename ...Rest>
43 struct push_front_map<T, map<Rest...>>
45 typedef map<T, Rest...> type;
47 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
49 call(T const& first, map<Rest...> const& rest)
51 return type(push_front(rest, first));
55 template <typename First, typename Last, bool is_assoc>
56 struct build_map<First, Last, is_assoc, false>
59 build_map<typename result_of::next<First>::type, Last, is_assoc>
62 typedef push_front_map<
63 typename pair_from<First, is_assoc>::type
64 , typename next_build_map::type>
67 typedef typename push_front::type type;
69 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
71 call(First const& f, Last const& l)
73 return push_front::call(
74 pair_from<First, is_assoc>::call(f)
75 , next_build_map::call(fusion::next(f), l));