1 /*=============================================================================
2 Copyright (c) 2001-2011 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(FUSION_MAP_MAIN_07212005_1106)
8 #define FUSION_MAP_MAIN_07212005_1106
10 #include <boost/fusion/support/config.hpp>
11 #include <boost/fusion/container/map/map_fwd.hpp>
12 #include <boost/fusion/support/pair.hpp>
14 ///////////////////////////////////////////////////////////////////////////////
15 // Without variadics, we will use the PP version
16 ///////////////////////////////////////////////////////////////////////////////
17 #if !defined(BOOST_FUSION_HAS_VARIADIC_MAP)
18 # include <boost/fusion/container/map/detail/cpp03/map.hpp>
21 ///////////////////////////////////////////////////////////////////////////////
23 ///////////////////////////////////////////////////////////////////////////////
24 #include <boost/fusion/container/map/detail/map_impl.hpp>
25 #include <boost/fusion/container/map/detail/begin_impl.hpp>
26 #include <boost/fusion/container/map/detail/end_impl.hpp>
27 #include <boost/fusion/container/map/detail/at_impl.hpp>
28 #include <boost/fusion/container/map/detail/at_key_impl.hpp>
29 #include <boost/fusion/container/map/detail/value_at_impl.hpp>
30 #include <boost/fusion/container/map/detail/value_at_key_impl.hpp>
31 #include <boost/fusion/sequence/intrinsic/begin.hpp>
32 #include <boost/fusion/sequence/intrinsic/end.hpp>
33 #include <boost/fusion/sequence/intrinsic/at.hpp>
34 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
35 #include <boost/fusion/support/is_sequence.hpp>
36 #include <boost/fusion/support/sequence_base.hpp>
37 #include <boost/fusion/support/category_of.hpp>
38 #include <boost/fusion/support/void.hpp>
39 #include <boost/fusion/support/detail/enabler.hpp>
41 #include <boost/utility/enable_if.hpp>
43 namespace boost { namespace fusion
47 template <typename ...T>
48 struct map : detail::map_impl<0, T...>, sequence_base<map<T...>>
50 typedef map_tag fusion_tag;
51 typedef detail::map_impl<0, T...> base_type;
53 struct category : random_access_traversal_tag, associative_tag {};
54 typedef mpl::int_<base_type::size> size;
55 typedef mpl::false_ is_view;
57 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
60 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
62 : base_type(seq.base())
65 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
67 : base_type(std::forward<map>(seq))
70 template <typename Sequence>
71 BOOST_FUSION_GPU_ENABLED
72 map(Sequence const& seq
73 , typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
74 : base_type(begin(seq), detail::map_impl_from_iterator())
77 template <typename Sequence>
78 BOOST_FUSION_GPU_ENABLED
80 , typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
81 : base_type(begin(seq), detail::map_impl_from_iterator())
84 template <typename Sequence>
85 BOOST_FUSION_GPU_ENABLED
87 , typename enable_if<traits::is_sequence<Sequence>, detail::enabler_>::type = detail::enabler)
88 : base_type(begin(seq), detail::map_impl_from_iterator())
91 template <typename First, typename ...T_>
92 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
93 map(First const& first, T_ const&... rest)
94 : base_type(first, rest...)
97 template <typename First, typename ...T_>
98 BOOST_FUSION_GPU_ENABLED
99 map(First&& first, T_&&... rest)
100 : base_type(BOOST_FUSION_FWD_ELEM(First, first), BOOST_FUSION_FWD_ELEM(T_, rest)...)
103 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
104 map& operator=(map const& rhs)
106 base_type::operator=(rhs.base());
110 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
111 map& operator=(map&& rhs)
113 base_type::operator=(std::forward<base_type>(rhs.base()));
117 template <typename Sequence>
118 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
119 typename enable_if<traits::is_sequence<Sequence>, map&>::type
120 operator=(Sequence const& seq)
122 base().assign(begin(seq), detail::map_impl_from_iterator());
126 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
127 base_type& base() BOOST_NOEXCEPT { return *this; }
128 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
129 base_type const& base() const BOOST_NOEXCEPT { return *this; }