40 template<
typename Key,
typename Head,
typename Tail>
41 class multi_type_map_wrapper
42 < Head, multi_type_map<Key, meta::type_list<Head, Tail> > >
45 typedef Head value_type;
46 typedef multi_type_map<Key, meta::type_list<Head, Tail> >
map_type;
47 typedef typename map_type::iterator_type iterator;
48 typedef typename map_type::const_iterator_type const_iterator;
51 static void erase(
map_type&
self, iterator it )
53 self.m_data.erase(it);
56 static std::size_t erase(
map_type&
self,
const key_type& k )
58 return self.m_data.erase(k);
61 static const value_type&
get(
const map_type&
self,
const key_type& k )
64 return self.m_data.find(k)->second;
67 static value_type&
get(
map_type&
self,
const key_type& k )
70 return self.m_data.find(k)->second;
73 static void set(
map_type&
self,
const key_type& k,
const value_type& v )
78 static bool exists(
const map_type&
self,
const key_type& k )
80 return self.m_data.find(k) !=
self.m_data.end();
83 static iterator begin(
map_type&
self )
85 return self.m_data.begin();
88 static iterator end(
map_type&
self )
90 return self.m_data.end();
93 static const_iterator begin(
const map_type&
self )
95 return self.m_data.begin();
98 static const_iterator end(
const map_type&
self )
100 return self.m_data.end();
109 template<
typename ValueType,
typename Key,
typename Head,
typename Tail>
110 class multi_type_map_wrapper
111 < ValueType, multi_type_map< Key, meta::type_list<Head, Tail> > >:
112 public multi_type_map_wrapper< ValueType, multi_type_map<Key, Tail> >
121 template<
typename Key,
typename Head,
typename Tail>
122 class multi_type_map_helper
123 < multi_type_map<Key, meta::type_list<Head, Tail> > >
125 typedef Key key_type;
126 typedef Head value_type;
127 typedef multi_type_map<Key, meta::type_list<Head, Tail> >
map_type;
128 typedef typename map_type::iterator_type iterator;
129 typedef typename map_type::const_iterator_type const_iterator;
134 for ( const_iterator it=that.template begin<value_type>();
135 it!=that.template end<value_type>(); ++it )
136 self.
template set<Head>( it->first, it->second );
138 multi_type_map_helper< multi_type_map<Key, Tail> >::set(
self, that );
141 static std::size_t size(
const map_type&
self )
143 return self.m_data.size()
144 + multi_type_map_helper< multi_type_map<Key, Tail> >::size(
self );
153 template<
typename Key>
154 class multi_type_map_helper
158 typedef multi_type_map<Key, claw::meta::no_type> map_type;
161 static void set( map_type&
self,
const map_type& that )
166 static std::size_t size(
const map_type&
self )
183 template<
typename Key,
typename Head,
typename Tail>
184 template<
typename ValueType>
186 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::erase
187 (
typename iterator<ValueType>::type it )
189 multi_type_map_wrapper<ValueType, self_type>::erase(*
this, it);
198 template<
typename Key,
typename Head,
typename Tail>
199 template<
typename ValueType>
201 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::erase
202 (
const key_type& k )
204 return multi_type_map_wrapper<ValueType, self_type>::erase(*
this, k);
212 template<
typename Key,
typename Head,
typename Tail>
213 template<
typename ValueType>
215 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::get
216 (
const key_type& k )
const
218 return multi_type_map_wrapper<ValueType, self_type>::get(*
this, k);
226 template<
typename Key,
typename Head,
typename Tail>
227 template<
typename ValueType>
228 ValueType& claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::get
229 (
const key_type& k )
231 return multi_type_map_wrapper<ValueType, self_type>::get(*
this, k);
240 template<
typename Key,
typename Head,
typename Tail>
241 template<
typename ValueType>
242 void claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::set
243 (
const key_type& k,
const ValueType& v )
245 return multi_type_map_wrapper<ValueType, self_type>::set(*
this, k, v);
254 template<
typename Key,
typename Head,
typename Tail>
255 void claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::set
256 (
const self_type& m )
258 multi_type_map_helper<self_type>::set(*
this, m);
266 template<
typename Key,
typename Head,
typename Tail>
267 template<
typename ValueType>
268 bool claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::exists
269 (
const key_type& k )
const
271 return multi_type_map_wrapper<ValueType, self_type>::exists(*
this, k);
278 template<
typename Key,
typename Head,
typename Tail>
280 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::size()
const
282 return multi_type_map_helper<self_type>::size(*
this);
289 template<
typename Key,
typename Head,
typename Tail>
290 template<
typename ValueType>
291 typename claw::multi_type_map
293 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::begin()
295 return multi_type_map_wrapper<ValueType, self_type>::begin(*
this);
302 template<
typename Key,
typename Head,
typename Tail>
303 template<
typename ValueType>
304 typename claw::multi_type_map
306 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::end()
308 return multi_type_map_wrapper<ValueType, self_type>::end(*
this);
315 template<
typename Key,
typename Head,
typename Tail>
316 template<
typename ValueType>
320 ::template iterator<ValueType>::const_type
321 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::begin()
const
323 return multi_type_map_wrapper<ValueType, self_type>::begin(*
this);
330 template<
typename Key,
typename Head,
typename Tail>
331 template<
typename ValueType>
335 ::template iterator<ValueType>::const_type
336 claw::multi_type_map< Key, claw::meta::type_list<Head, Tail> >::end()
const
338 return multi_type_map_wrapper<ValueType, self_type>::end(*
this);