File indexing completed on 2025-01-18 09:33:39
0001
0002
0003
0004
0005
0006
0007 #if !defined(BOOST_FUSION_MAP_IMPL_02032013_2233)
0008 #define BOOST_FUSION_MAP_IMPL_02032013_2233
0009
0010 #include <boost/fusion/support/config.hpp>
0011 #include <boost/fusion/support/detail/access.hpp>
0012 #include <boost/fusion/iterator/deref.hpp>
0013 #include <boost/fusion/iterator/next.hpp>
0014 #include <boost/mpl/int.hpp>
0015 #include <boost/mpl/identity.hpp>
0016
0017 namespace boost { namespace fusion
0018 {
0019 struct fusion_sequence_tag;
0020 }}
0021
0022 namespace boost { namespace fusion { namespace detail
0023 {
0024 struct map_impl_from_iterator {};
0025
0026 template <int index, typename ...T>
0027 struct map_impl;
0028
0029 template <int index_>
0030 struct map_impl<index_>
0031 {
0032 typedef fusion_sequence_tag tag;
0033 static int const index = index_;
0034 static int const size = 0;
0035
0036 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0037 map_impl() BOOST_NOEXCEPT {}
0038
0039 template <typename Iterator>
0040 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0041 map_impl(Iterator const&, map_impl_from_iterator) BOOST_NOEXCEPT
0042 {}
0043
0044 template <typename Iterator>
0045 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0046 void assign(Iterator const&, map_impl_from_iterator) BOOST_NOEXCEPT
0047 {}
0048
0049 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0050 void get();
0051 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0052 void get_val();
0053 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0054 void get_key();
0055 };
0056
0057 template <int index_, typename Pair, typename ...T>
0058 struct map_impl<index_, Pair, T...> : map_impl<index_ + 1, T...>
0059 {
0060 typedef fusion_sequence_tag tag;
0061 typedef map_impl<index_+1, T...> rest_type;
0062
0063 using rest_type::get;
0064 using rest_type::get_val;
0065 using rest_type::get_key;
0066
0067 static int const index = index_;
0068 static int const size = rest_type::size + 1;
0069
0070 typedef Pair pair_type;
0071 typedef typename Pair::first_type key_type;
0072 typedef typename Pair::second_type value_type;
0073
0074 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0075 map_impl()
0076 : rest_type(), element()
0077 {}
0078
0079 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0080 map_impl(map_impl const& rhs)
0081 : rest_type(rhs.get_base()), element(rhs.element)
0082 {}
0083
0084 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0085 map_impl(map_impl&& rhs)
0086 : rest_type(BOOST_FUSION_FWD_ELEM(rest_type, *static_cast<rest_type*>(&rhs)))
0087 , element(BOOST_FUSION_FWD_ELEM(Pair, rhs.element))
0088 {}
0089
0090 template <typename ...U>
0091 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0092 map_impl(map_impl<index, U...> const& rhs)
0093 : rest_type(rhs.get_base()), element(rhs.element)
0094 {}
0095
0096 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0097 map_impl(typename detail::call_param<Pair>::type element_
0098 , typename detail::call_param<T>::type... rest)
0099 : rest_type(rest...), element(element_)
0100 {}
0101
0102 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0103 map_impl(Pair&& element_, T&&... rest)
0104 : rest_type(BOOST_FUSION_FWD_ELEM(T, rest)...)
0105 , element(BOOST_FUSION_FWD_ELEM(Pair, element_))
0106 {}
0107
0108 template <typename Iterator>
0109 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0110 map_impl(Iterator const& iter, map_impl_from_iterator fi)
0111 : rest_type(fusion::next(iter), fi)
0112 , element(*iter)
0113 {}
0114
0115 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0116 rest_type& get_base()
0117 {
0118 return *this;
0119 }
0120
0121 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0122 rest_type const& get_base() const
0123 {
0124 return *this;
0125 }
0126
0127 BOOST_FUSION_GPU_ENABLED
0128 mpl::identity<value_type> get_val(mpl::identity<key_type>) const;
0129 BOOST_FUSION_GPU_ENABLED
0130 pair_type get_val(mpl::int_<index>) const;
0131
0132 BOOST_FUSION_GPU_ENABLED
0133 mpl::identity<key_type> get_key(mpl::int_<index>);
0134 BOOST_FUSION_GPU_ENABLED
0135 mpl::identity<key_type> get_key(mpl::int_<index>) const;
0136
0137 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0138 typename cref_result<value_type>::type
0139 get(mpl::identity<key_type>) const
0140 {
0141 return element.second;
0142 }
0143
0144 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0145 typename ref_result<value_type>::type
0146 get(mpl::identity<key_type>)
0147 {
0148 return element.second;
0149 }
0150
0151 BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0152 typename cref_result<pair_type>::type
0153 get(mpl::int_<index>) const
0154 {
0155 return element;
0156 }
0157
0158 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0159 typename ref_result<pair_type>::type
0160 get(mpl::int_<index>)
0161 {
0162 return element;
0163 }
0164
0165 template <typename ...U>
0166 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0167 map_impl& operator=(map_impl<index, U...> const& rhs)
0168 {
0169 rest_type::operator=(rhs);
0170 element = rhs.element;
0171 return *this;
0172 }
0173
0174 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0175 map_impl& operator=(map_impl const& rhs)
0176 {
0177 rest_type::operator=(rhs);
0178 element = rhs.element;
0179 return *this;
0180 }
0181
0182 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0183 map_impl& operator=(map_impl&& rhs)
0184 {
0185 rest_type::operator=(std::forward<map_impl>(rhs));
0186 element = BOOST_FUSION_FWD_ELEM(Pair, rhs.element);
0187 return *this;
0188 }
0189
0190 template <typename Iterator>
0191 BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED
0192 void assign(Iterator const& iter, map_impl_from_iterator fi)
0193 {
0194 rest_type::assign(fusion::next(iter), fi);
0195 element = *iter;
0196 }
0197
0198 Pair element;
0199 };
0200 }}}
0201
0202 #endif