Chris@16
|
1 /*=============================================================================
|
Chris@16
|
2 Copyright (c) 2004 Angus Leeming
|
Chris@16
|
3 Copyright (c) 2004 Joel de Guzman
|
Chris@16
|
4
|
Chris@16
|
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
|
Chris@16
|
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 ==============================================================================*/
|
Chris@16
|
8 #ifndef BOOST_PHOENIX_STL_CONTAINER_CONTAINER_HPP
|
Chris@16
|
9 #define BOOST_PHOENIX_STL_CONTAINER_CONTAINER_HPP
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/phoenix/core/limits.hpp>
|
Chris@16
|
12 #include <boost/mpl/and.hpp>
|
Chris@16
|
13 #include <boost/mpl/not.hpp>
|
Chris@16
|
14 #include <boost/mpl/or.hpp>
|
Chris@16
|
15 #include <boost/mpl/void.hpp>
|
Chris@16
|
16 #include <boost/phoenix/stl/container/detail/container.hpp>
|
Chris@16
|
17 #include <boost/phoenix/function/adapt_callable.hpp>
|
Chris@16
|
18 #include <boost/type_traits/is_const.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace phoenix
|
Chris@16
|
21 {
|
Chris@16
|
22 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
23 //
|
Chris@16
|
24 // STL container member functions
|
Chris@16
|
25 //
|
Chris@16
|
26 // Lazy functions for STL container member functions
|
Chris@16
|
27 //
|
Chris@16
|
28 // These functions provide a mechanism for the lazy evaluation of the
|
Chris@16
|
29 // public member functions of the STL containers. For an overview of
|
Chris@16
|
30 // what is meant by 'lazy evaluation', see the comments in operators.hpp
|
Chris@16
|
31 // and functions.hpp.
|
Chris@16
|
32 //
|
Chris@16
|
33 // Lazy functions are provided for all of the member functions of the
|
Chris@16
|
34 // following containers:
|
Chris@16
|
35 //
|
Chris@16
|
36 // deque - list - map - multimap - vector.
|
Chris@16
|
37 //
|
Chris@16
|
38 // Indeed, should *your* class have member functions with the same names
|
Chris@16
|
39 // and signatures as those listed below, then it will automatically be
|
Chris@16
|
40 // supported. To summarize, lazy functions are provided for member
|
Chris@16
|
41 // functions:
|
Chris@16
|
42 //
|
Chris@16
|
43 // assign - at - back - begin - capacity - clear - empty - end -
|
Chris@16
|
44 // erase - front - get_allocator - insert - key_comp - max_size -
|
Chris@16
|
45 // pop_back - pop_front - push_back - push_front - rbegin - rend -
|
Chris@16
|
46 // reserve - resize . size - splice - value_comp.
|
Chris@16
|
47 //
|
Chris@16
|
48 // The lazy functions' names are the same as the corresponding member
|
Chris@16
|
49 // function. Sample usage:
|
Chris@16
|
50 //
|
Chris@16
|
51 // "Normal" version "Lazy" version
|
Chris@16
|
52 // ---------------- --------------
|
Chris@16
|
53 // my_vector.at(5) phoenix::at(arg1, 5)
|
Chris@16
|
54 // my_list.size() phoenix::size(arg1)
|
Chris@16
|
55 // my_vector1.swap(my_vector2) phoenix::swap(arg1, arg2)
|
Chris@16
|
56 //
|
Chris@16
|
57 // Notice that member functions with names that clash with a
|
Chris@16
|
58 // function in stl algorithms are absent. This will be provided
|
Chris@16
|
59 // in Phoenix's algorithm module.
|
Chris@16
|
60 //
|
Chris@16
|
61 // No support is provided here for lazy versions of operator+=,
|
Chris@16
|
62 // operator[] etc. Such operators are not specific to STL containers and
|
Chris@16
|
63 // lazy versions can therefore be found in operators.hpp.
|
Chris@16
|
64 //
|
Chris@16
|
65 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
66
|
Chris@16
|
67 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
68 //
|
Chris@16
|
69 // Lazy member function implementaions.
|
Chris@16
|
70 //
|
Chris@16
|
71 // The structs below provide the guts of the implementation. Thereafter,
|
Chris@16
|
72 // the corresponding lazy function itself is simply:
|
Chris@16
|
73 //
|
Chris@16
|
74 // function<stl::assign> const assign = stl::assign();
|
Chris@16
|
75 //
|
Chris@16
|
76 // The structs provide a nested "result" class template whose
|
Chris@16
|
77 // "type" typedef enables the lazy function to ascertain the type
|
Chris@16
|
78 // to be returned when it is invoked.
|
Chris@16
|
79 //
|
Chris@16
|
80 // They also provide operator() member functions with signatures
|
Chris@16
|
81 // corresponding to those of the underlying member function of
|
Chris@16
|
82 // the STL container.
|
Chris@16
|
83 //
|
Chris@16
|
84 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
85 namespace stl
|
Chris@16
|
86 {
|
Chris@16
|
87 struct assign
|
Chris@16
|
88 {
|
Chris@16
|
89 template <typename Sig>
|
Chris@16
|
90 struct result;
|
Chris@16
|
91
|
Chris@16
|
92 template <
|
Chris@16
|
93 typename This
|
Chris@16
|
94 , typename C
|
Chris@16
|
95 , typename Arg1
|
Chris@16
|
96 >
|
Chris@16
|
97 struct result<This(C&, Arg1 const &)>
|
Chris@16
|
98 {
|
Chris@16
|
99 typedef typename add_reference<C>::type type;
|
Chris@16
|
100 };
|
Chris@16
|
101
|
Chris@16
|
102 template <
|
Chris@16
|
103 typename This
|
Chris@16
|
104 , typename C
|
Chris@16
|
105 , typename Arg1
|
Chris@16
|
106 , typename Arg2
|
Chris@16
|
107 >
|
Chris@16
|
108 struct result<This(C&, Arg1, Arg2)>
|
Chris@16
|
109 {
|
Chris@16
|
110 typedef typename add_reference<C>::type type;
|
Chris@16
|
111 };
|
Chris@16
|
112
|
Chris@16
|
113 template <
|
Chris@16
|
114 typename This
|
Chris@16
|
115 , typename C
|
Chris@16
|
116 , typename Arg1
|
Chris@16
|
117 , typename Arg2
|
Chris@16
|
118 , typename Arg3
|
Chris@16
|
119 >
|
Chris@16
|
120 struct result<This(C&, Arg1, Arg2, Arg3)>
|
Chris@16
|
121 {
|
Chris@16
|
122 typedef typename add_reference<C>::type type;
|
Chris@16
|
123 };
|
Chris@16
|
124
|
Chris@16
|
125 template <typename C, typename Arg1>
|
Chris@16
|
126 C& operator()(C& c, Arg1 const & arg1) const
|
Chris@16
|
127 {
|
Chris@16
|
128 c.assign(arg1);
|
Chris@16
|
129 return c;
|
Chris@16
|
130 }
|
Chris@16
|
131
|
Chris@16
|
132 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
133 C& operator()(C& c, Arg1 arg1, Arg2 arg2) const
|
Chris@16
|
134 {
|
Chris@16
|
135 c.assign(arg1, arg2);
|
Chris@16
|
136 return c;
|
Chris@16
|
137 }
|
Chris@16
|
138
|
Chris@16
|
139 template <typename C, typename Arg1, typename Arg2, typename Arg3>
|
Chris@16
|
140 C& operator()(
|
Chris@16
|
141 C& c
|
Chris@16
|
142 , Arg1 arg1
|
Chris@16
|
143 , Arg2 arg2
|
Chris@16
|
144 , Arg3 const & arg3
|
Chris@16
|
145 ) const
|
Chris@16
|
146 {
|
Chris@16
|
147 return c.assign(arg1, arg2, arg3);
|
Chris@16
|
148 }
|
Chris@16
|
149 };
|
Chris@16
|
150
|
Chris@16
|
151 struct at_impl
|
Chris@16
|
152 {
|
Chris@16
|
153 template <typename Sig>
|
Chris@16
|
154 struct result;
|
Chris@16
|
155
|
Chris@16
|
156 template <typename This, typename C, typename Index>
|
Chris@16
|
157 struct result<This(C&, Index)>
|
Chris@16
|
158 {
|
Chris@16
|
159 //typedef typename const_qualified_reference_of<C>::type type;
|
Chris@16
|
160 typedef typename C::value_type & type;
|
Chris@16
|
161 };
|
Chris@16
|
162
|
Chris@16
|
163 template <typename C, typename Index>
|
Chris@16
|
164 typename result<at_impl(C&, Index const&)>::type
|
Chris@16
|
165 operator()(C& c, Index const &i) const
|
Chris@16
|
166 {
|
Chris@16
|
167 return c.at(i);
|
Chris@16
|
168 }
|
Chris@16
|
169
|
Chris@16
|
170 template <typename This, typename C, typename Index>
|
Chris@16
|
171 struct result<This(C const&, Index)>
|
Chris@16
|
172 {
|
Chris@16
|
173 typedef typename C::value_type const & type;
|
Chris@16
|
174 };
|
Chris@16
|
175
|
Chris@16
|
176 template <typename C, typename Index>
|
Chris@16
|
177 typename result<at_impl(C const&, Index const&)>::type
|
Chris@16
|
178 operator()(C const& c, Index const &i) const
|
Chris@16
|
179 {
|
Chris@16
|
180 return c.at(i);
|
Chris@16
|
181 }
|
Chris@16
|
182 };
|
Chris@16
|
183
|
Chris@16
|
184 struct back
|
Chris@16
|
185 {
|
Chris@16
|
186 template <typename Sig>
|
Chris@16
|
187 struct result;
|
Chris@16
|
188
|
Chris@16
|
189 template <typename This, typename C>
|
Chris@16
|
190 struct result<This(C&)>
|
Chris@16
|
191 {
|
Chris@16
|
192 typedef
|
Chris@16
|
193 typename const_qualified_reference_of<C>::type
|
Chris@16
|
194 type;
|
Chris@16
|
195 };
|
Chris@16
|
196
|
Chris@16
|
197 template <typename C>
|
Chris@16
|
198 typename result<back(C&)>::type
|
Chris@16
|
199 operator()(C& c) const
|
Chris@16
|
200 {
|
Chris@16
|
201 return c.back();
|
Chris@16
|
202 }
|
Chris@16
|
203 };
|
Chris@16
|
204
|
Chris@16
|
205 struct begin
|
Chris@16
|
206 {
|
Chris@16
|
207 template <typename Sig>
|
Chris@16
|
208 struct result;
|
Chris@16
|
209
|
Chris@16
|
210 template <typename This, typename C>
|
Chris@16
|
211 struct result<This(C&)>
|
Chris@16
|
212 {
|
Chris@16
|
213 typedef typename const_qualified_iterator_of<C>::type type;
|
Chris@16
|
214 };
|
Chris@16
|
215
|
Chris@16
|
216 template <typename C>
|
Chris@16
|
217 typename result<begin(C&)>::type
|
Chris@16
|
218 operator()(C& c) const
|
Chris@16
|
219 {
|
Chris@16
|
220 return c.begin();
|
Chris@16
|
221 }
|
Chris@16
|
222 };
|
Chris@16
|
223
|
Chris@16
|
224 struct capacity
|
Chris@16
|
225 {
|
Chris@16
|
226 template <typename Sig>
|
Chris@16
|
227 struct result;
|
Chris@16
|
228
|
Chris@16
|
229 template <typename This, typename C>
|
Chris@16
|
230 struct result<This(C&)>
|
Chris@16
|
231 {
|
Chris@16
|
232 typedef typename size_type_of<C>::type type;
|
Chris@16
|
233 };
|
Chris@16
|
234
|
Chris@16
|
235 template <typename C>
|
Chris@16
|
236 typename result<capacity(C&)>::type
|
Chris@16
|
237 operator()(C const& c) const
|
Chris@16
|
238 {
|
Chris@16
|
239 return c.capacity();
|
Chris@16
|
240 }
|
Chris@16
|
241 };
|
Chris@16
|
242
|
Chris@16
|
243 struct clear
|
Chris@16
|
244 {
|
Chris@16
|
245 typedef void result_type;
|
Chris@16
|
246
|
Chris@16
|
247 template <typename C>
|
Chris@16
|
248 void operator()(C& c) const
|
Chris@16
|
249 {
|
Chris@16
|
250 return c.clear();
|
Chris@16
|
251 }
|
Chris@16
|
252 };
|
Chris@16
|
253
|
Chris@16
|
254 struct empty
|
Chris@16
|
255 {
|
Chris@16
|
256 typedef bool result_type;
|
Chris@16
|
257
|
Chris@16
|
258 template <typename C>
|
Chris@16
|
259 bool operator()(C const& c) const
|
Chris@16
|
260 {
|
Chris@16
|
261 return c.empty();
|
Chris@16
|
262 }
|
Chris@16
|
263 };
|
Chris@16
|
264
|
Chris@16
|
265 struct end
|
Chris@16
|
266 {
|
Chris@16
|
267 template <typename Sig>
|
Chris@16
|
268 struct result;
|
Chris@16
|
269
|
Chris@16
|
270 template <typename This, typename C>
|
Chris@16
|
271 struct result<This(C&)>
|
Chris@16
|
272 {
|
Chris@16
|
273 typedef typename const_qualified_iterator_of<C>::type type;
|
Chris@16
|
274 };
|
Chris@16
|
275
|
Chris@16
|
276 template <typename C>
|
Chris@16
|
277 typename result<end(C&)>::type
|
Chris@16
|
278 operator()(C& c) const
|
Chris@16
|
279 {
|
Chris@16
|
280 return c.end();
|
Chris@16
|
281 }
|
Chris@16
|
282 };
|
Chris@16
|
283
|
Chris@16
|
284 namespace result_of
|
Chris@16
|
285 {
|
Chris@16
|
286 template <typename C, typename Arg1, typename Arg2 = mpl::void_>
|
Chris@16
|
287 struct erase
|
Chris@16
|
288 {
|
Chris@16
|
289 // BOOST_MSVC #if branch here in map_erase_result non-
|
Chris@16
|
290 // standard behavior. The return type should be void but
|
Chris@16
|
291 // VC7.1 prefers to return iterator_of<C>. As a result,
|
Chris@16
|
292 // VC7.1 complains of error C2562:
|
Chris@16
|
293 // boost::phoenix::stl::erase::operator() 'void' function
|
Chris@16
|
294 // returning a value. Oh well... :*
|
Chris@16
|
295
|
Chris@16
|
296 typedef
|
Chris@16
|
297 boost::mpl::eval_if_c<
|
Chris@16
|
298 boost::is_same<
|
Chris@16
|
299 typename remove_reference<Arg1>::type
|
Chris@16
|
300 , typename iterator_of<C>::type
|
Chris@16
|
301 >::value
|
Chris@16
|
302 #if defined(BOOST_MSVC)// && (BOOST_MSVC <= 1500)
|
Chris@16
|
303 , iterator_of<C>
|
Chris@16
|
304 #else
|
Chris@16
|
305 , boost::mpl::identity<void>
|
Chris@16
|
306 #endif
|
Chris@16
|
307 , size_type_of<C>
|
Chris@16
|
308 >
|
Chris@16
|
309 map_erase_result;
|
Chris@16
|
310
|
Chris@16
|
311 typedef typename
|
Chris@16
|
312 boost::mpl::eval_if_c<
|
Chris@16
|
313 has_mapped_type<C>::value
|
Chris@16
|
314 , map_erase_result
|
Chris@16
|
315 , iterator_of<C>
|
Chris@16
|
316 >::type
|
Chris@16
|
317 type;
|
Chris@16
|
318 };
|
Chris@16
|
319 }
|
Chris@16
|
320
|
Chris@16
|
321 struct erase
|
Chris@16
|
322 {
|
Chris@16
|
323 // This mouthful can differentiate between the generic erase
|
Chris@16
|
324 // functions (Container == std::deque, std::list, std::vector) and
|
Chris@16
|
325 // that specific to the two map-types, std::map and std::multimap.
|
Chris@16
|
326 //
|
Chris@16
|
327 // where C is a std::deque, std::list, std::vector:
|
Chris@16
|
328 //
|
Chris@16
|
329 // 1) iterator C::erase(iterator where);
|
Chris@16
|
330 // 2) iterator C::erase(iterator first, iterator last);
|
Chris@16
|
331 //
|
Chris@16
|
332 // where M is a std::map or std::multimap:
|
Chris@16
|
333 //
|
Chris@16
|
334 // 3) size_type M::erase(const Key& keyval);
|
Chris@16
|
335 // 4) void M::erase(iterator where);
|
Chris@16
|
336 // 5) void M::erase(iterator first, iterator last);
|
Chris@16
|
337
|
Chris@16
|
338 template <typename Sig>
|
Chris@16
|
339 struct result;
|
Chris@16
|
340
|
Chris@16
|
341 template <typename This, typename C, typename Arg1>
|
Chris@16
|
342 struct result<This(C&, Arg1)>
|
Chris@16
|
343 : result_of::erase<C, Arg1>
|
Chris@16
|
344 {};
|
Chris@16
|
345
|
Chris@16
|
346 template <typename This, typename C, typename Arg1, typename Arg2>
|
Chris@16
|
347 struct result<This(C&, Arg1, Arg2)>
|
Chris@16
|
348 : result_of::erase<C, Arg1, Arg2>
|
Chris@16
|
349 {};
|
Chris@16
|
350
|
Chris@16
|
351 template <typename C, typename Arg1>
|
Chris@16
|
352 typename stl_impl::disable_if_is_void<
|
Chris@16
|
353 typename result_of::erase<C, Arg1>::type
|
Chris@16
|
354 >::type
|
Chris@16
|
355 operator()(C& c, Arg1 arg1) const
|
Chris@16
|
356 {
|
Chris@16
|
357 return c.erase(arg1);
|
Chris@16
|
358 }
|
Chris@16
|
359
|
Chris@16
|
360 template <typename C, typename Arg1>
|
Chris@16
|
361 typename stl_impl::enable_if_is_void<
|
Chris@16
|
362 typename result_of::erase<C, Arg1>::type
|
Chris@16
|
363 >::type
|
Chris@16
|
364 operator()(C& c, Arg1 arg1) const
|
Chris@16
|
365 {
|
Chris@16
|
366 c.erase(arg1);
|
Chris@16
|
367 }
|
Chris@16
|
368
|
Chris@16
|
369 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
370 typename stl_impl::disable_if_is_void<
|
Chris@16
|
371 typename result_of::erase<C, Arg1, Arg2>::type
|
Chris@16
|
372 >::type
|
Chris@16
|
373 operator()(C& c, Arg1 arg1, Arg2 arg2) const
|
Chris@16
|
374 {
|
Chris@16
|
375 return c.erase(arg1, arg2);
|
Chris@16
|
376 }
|
Chris@16
|
377
|
Chris@16
|
378 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
379 typename stl_impl::enable_if_is_void<
|
Chris@16
|
380 typename result_of::erase<C, Arg1, Arg2>::type
|
Chris@16
|
381 >::type
|
Chris@16
|
382 operator()(C& c, Arg1 arg1, Arg2 arg2) const
|
Chris@16
|
383 {
|
Chris@16
|
384 c.erase(arg1, arg2);
|
Chris@16
|
385 }
|
Chris@16
|
386 };
|
Chris@16
|
387
|
Chris@16
|
388 struct front
|
Chris@16
|
389 {
|
Chris@16
|
390 template <typename Sig>
|
Chris@16
|
391 struct result;
|
Chris@16
|
392
|
Chris@16
|
393 template <typename This, typename C>
|
Chris@16
|
394 struct result<This(C&)>
|
Chris@16
|
395 {
|
Chris@16
|
396 typedef typename const_qualified_reference_of<C>::type type;
|
Chris@16
|
397 };
|
Chris@16
|
398
|
Chris@16
|
399 template <typename C>
|
Chris@16
|
400 typename result<front(C&)>::type
|
Chris@16
|
401 operator()(C& c) const
|
Chris@16
|
402 {
|
Chris@16
|
403 return c.front();
|
Chris@16
|
404 }
|
Chris@16
|
405 };
|
Chris@16
|
406
|
Chris@16
|
407 struct get_allocator
|
Chris@16
|
408 {
|
Chris@16
|
409 template <typename Sig>
|
Chris@16
|
410 struct result;
|
Chris@16
|
411
|
Chris@16
|
412 template <typename This, typename C>
|
Chris@16
|
413 struct result<This(C&)>
|
Chris@16
|
414 {
|
Chris@16
|
415 typedef typename allocator_type_of<C>::type type;
|
Chris@16
|
416 };
|
Chris@16
|
417
|
Chris@16
|
418 template <typename C>
|
Chris@16
|
419 typename result<get_allocator(C const&)>::type
|
Chris@16
|
420 operator()(C& c) const
|
Chris@16
|
421 {
|
Chris@16
|
422 return c.get_allocator();
|
Chris@16
|
423 }
|
Chris@16
|
424 };
|
Chris@16
|
425
|
Chris@16
|
426 namespace result_of
|
Chris@16
|
427 {
|
Chris@16
|
428 template <
|
Chris@16
|
429 typename C
|
Chris@16
|
430 , typename Arg1
|
Chris@16
|
431 , typename Arg2 = mpl::void_
|
Chris@16
|
432 , typename Arg3 = mpl::void_
|
Chris@16
|
433 >
|
Chris@16
|
434 class insert
|
Chris@16
|
435 {
|
Chris@16
|
436 struct pair_iterator_bool
|
Chris@16
|
437 {
|
Chris@16
|
438 typedef typename std::pair<typename C::iterator, bool> type;
|
Chris@16
|
439 };
|
Chris@16
|
440
|
Chris@16
|
441 typedef
|
Chris@16
|
442 boost::mpl::eval_if<
|
Chris@16
|
443 map_insert_returns_pair<typename remove_const<C>::type>
|
Chris@16
|
444 , pair_iterator_bool
|
Chris@16
|
445 , iterator_of<C>
|
Chris@16
|
446 >
|
Chris@16
|
447 choice_1;
|
Chris@16
|
448
|
Chris@16
|
449 typedef
|
Chris@16
|
450 boost::mpl::eval_if_c<
|
Chris@16
|
451 boost::mpl::and_<
|
Chris@16
|
452 boost::is_same<Arg3, mpl::void_>
|
Chris@16
|
453 , boost::mpl::not_<boost::is_same<Arg1, Arg2> >
|
Chris@16
|
454 >::value
|
Chris@16
|
455 , iterator_of<C>
|
Chris@16
|
456 , boost::mpl::identity<void>
|
Chris@16
|
457 >
|
Chris@16
|
458 choice_2;
|
Chris@16
|
459
|
Chris@16
|
460 public:
|
Chris@16
|
461
|
Chris@16
|
462 typedef typename
|
Chris@16
|
463 boost::mpl::eval_if_c<
|
Chris@16
|
464 boost::is_same<Arg2, mpl::void_>::value
|
Chris@16
|
465 , choice_1
|
Chris@16
|
466 , choice_2
|
Chris@16
|
467 >::type
|
Chris@16
|
468 type;
|
Chris@16
|
469 };
|
Chris@16
|
470 }
|
Chris@16
|
471
|
Chris@16
|
472 struct insert
|
Chris@16
|
473 {
|
Chris@16
|
474 // This mouthful can differentiate between the generic insert
|
Chris@16
|
475 // functions (Container == deque, list, vector) and those
|
Chris@16
|
476 // specific to the two map-types, std::map and std::multimap.
|
Chris@16
|
477 //
|
Chris@16
|
478 // where C is a std::deque, std::list, std::vector:
|
Chris@16
|
479 //
|
Chris@16
|
480 // 1) iterator C::insert(iterator where, value_type value);
|
Chris@16
|
481 // 2) void C::insert(
|
Chris@16
|
482 // iterator where, size_type count, value_type value);
|
Chris@16
|
483 // 3) template <typename Iter>
|
Chris@16
|
484 // void C::insert(iterator where, Iter first, Iter last);
|
Chris@16
|
485 //
|
Chris@16
|
486 // where M is a std::map and MM is a std::multimap:
|
Chris@16
|
487 //
|
Chris@16
|
488 // 4) pair<iterator, bool> M::insert(value_type const&);
|
Chris@16
|
489 // 5) iterator MM::insert(value_type const&);
|
Chris@16
|
490 //
|
Chris@16
|
491 // where M is a std::map or std::multimap:
|
Chris@16
|
492 //
|
Chris@16
|
493 // 6) template <typename Iter>
|
Chris@16
|
494 // void M::insert(Iter first, Iter last);
|
Chris@16
|
495
|
Chris@16
|
496 template <typename Sig>
|
Chris@16
|
497 struct result;
|
Chris@16
|
498
|
Chris@16
|
499 template <
|
Chris@16
|
500 typename This
|
Chris@16
|
501 , typename C
|
Chris@16
|
502 , typename Arg1
|
Chris@16
|
503 >
|
Chris@16
|
504 struct result<This(C &, Arg1)>
|
Chris@16
|
505 : result_of::insert<C, Arg1>
|
Chris@16
|
506 {};
|
Chris@16
|
507
|
Chris@16
|
508 template <
|
Chris@16
|
509 typename This
|
Chris@16
|
510 , typename C
|
Chris@16
|
511 , typename Arg1
|
Chris@16
|
512 , typename Arg2
|
Chris@16
|
513 >
|
Chris@16
|
514 struct result<This(C &, Arg1, Arg2)>
|
Chris@16
|
515 : result_of::insert<C, Arg1, Arg2>
|
Chris@16
|
516 {};
|
Chris@16
|
517
|
Chris@16
|
518 template <
|
Chris@16
|
519 typename This
|
Chris@16
|
520 , typename C
|
Chris@16
|
521 , typename Arg1
|
Chris@16
|
522 , typename Arg2
|
Chris@16
|
523 , typename Arg3
|
Chris@16
|
524 >
|
Chris@16
|
525 struct result<This(C &, Arg1, Arg2, Arg3)>
|
Chris@16
|
526 : result_of::insert<C, Arg1, Arg2, Arg3>
|
Chris@16
|
527 {};
|
Chris@16
|
528
|
Chris@16
|
529 template <typename C, typename Arg1>
|
Chris@16
|
530 typename result<insert(C&, Arg1)>::type
|
Chris@16
|
531 operator()(C& c, Arg1 arg1) const
|
Chris@16
|
532 {
|
Chris@16
|
533 return c.insert(arg1);
|
Chris@16
|
534 }
|
Chris@16
|
535
|
Chris@16
|
536 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
537 typename stl_impl::disable_if_is_void<
|
Chris@16
|
538 typename result<insert(C&, Arg1, Arg2)>::type
|
Chris@16
|
539 >::type
|
Chris@16
|
540 operator()(C& c, Arg1 arg1, Arg2 arg2) const
|
Chris@16
|
541 {
|
Chris@16
|
542 return c.insert(arg1, arg2);
|
Chris@16
|
543 }
|
Chris@16
|
544
|
Chris@16
|
545 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
546 typename stl_impl::enable_if_is_void<
|
Chris@16
|
547 typename result<insert(C&, Arg1, Arg2)>::type
|
Chris@16
|
548 >::type
|
Chris@16
|
549 operator()(C& c, Arg1 arg1, Arg2 arg2) const
|
Chris@16
|
550 {
|
Chris@16
|
551 c.insert(arg1, arg2);
|
Chris@16
|
552 }
|
Chris@16
|
553
|
Chris@16
|
554 template <typename C, typename Arg1, typename Arg2, typename Arg3>
|
Chris@16
|
555 typename stl_impl::disable_if_is_void<
|
Chris@16
|
556 typename result<insert(C&, Arg1, Arg2, Arg3)>::type
|
Chris@16
|
557 >::type
|
Chris@16
|
558 operator()(
|
Chris@16
|
559 C& c, Arg1 arg1, Arg2 arg2, Arg3 arg3) const
|
Chris@16
|
560 {
|
Chris@16
|
561 return c.insert(arg1, arg2, arg3);
|
Chris@16
|
562 }
|
Chris@16
|
563
|
Chris@16
|
564 template <typename C, typename Arg1, typename Arg2, typename Arg3>
|
Chris@16
|
565 typename stl_impl::enable_if_is_void<
|
Chris@16
|
566 typename result<insert(C&, Arg1, Arg2, Arg3)>::type
|
Chris@16
|
567 >::type
|
Chris@16
|
568 operator()(
|
Chris@16
|
569 C& c, Arg1 arg1, Arg2 arg2, Arg3 arg3) const
|
Chris@16
|
570 {
|
Chris@16
|
571 c.insert(arg1, arg2, arg3);
|
Chris@16
|
572 }
|
Chris@16
|
573 };
|
Chris@16
|
574
|
Chris@16
|
575 namespace result_of
|
Chris@16
|
576 {
|
Chris@16
|
577 template <typename C>
|
Chris@16
|
578 struct key_comp
|
Chris@16
|
579 {
|
Chris@16
|
580 typedef typename key_compare_of<C>::type type;
|
Chris@16
|
581 };
|
Chris@16
|
582 }
|
Chris@16
|
583
|
Chris@16
|
584 struct key_comp
|
Chris@16
|
585 {
|
Chris@16
|
586 template <typename Sig>
|
Chris@16
|
587 struct result;
|
Chris@16
|
588
|
Chris@16
|
589 template <typename This, typename C>
|
Chris@16
|
590 struct result<This(C&)>
|
Chris@16
|
591 : result_of::key_comp<C>
|
Chris@16
|
592 {};
|
Chris@16
|
593
|
Chris@16
|
594 template <typename C>
|
Chris@16
|
595 typename result_of::key_comp<C>::type
|
Chris@16
|
596 operator()(C& c) const
|
Chris@16
|
597 {
|
Chris@16
|
598 return c.key_comp();
|
Chris@16
|
599 }
|
Chris@16
|
600 };
|
Chris@16
|
601
|
Chris@16
|
602 struct max_size
|
Chris@16
|
603 {
|
Chris@16
|
604 template <typename Sig>
|
Chris@16
|
605 struct result;
|
Chris@16
|
606
|
Chris@16
|
607 template <typename This, typename C>
|
Chris@16
|
608 struct result<This(C&)>
|
Chris@16
|
609 {
|
Chris@16
|
610 typedef typename size_type_of<C>::type type;
|
Chris@16
|
611 };
|
Chris@16
|
612
|
Chris@16
|
613 template <typename C>
|
Chris@16
|
614 typename result<max_size(C const&)>::type
|
Chris@16
|
615 operator()(C& c) const
|
Chris@16
|
616 {
|
Chris@16
|
617 return c.max_size();
|
Chris@16
|
618 }
|
Chris@16
|
619 };
|
Chris@16
|
620
|
Chris@16
|
621 struct pop_back
|
Chris@16
|
622 {
|
Chris@16
|
623 typedef void result_type;
|
Chris@16
|
624
|
Chris@16
|
625 template <typename C>
|
Chris@16
|
626 void operator()(C& c) const
|
Chris@16
|
627 {
|
Chris@16
|
628 return c.pop_back();
|
Chris@16
|
629 }
|
Chris@16
|
630 };
|
Chris@16
|
631
|
Chris@16
|
632 struct pop_front
|
Chris@16
|
633 {
|
Chris@16
|
634 typedef void result_type;
|
Chris@16
|
635
|
Chris@16
|
636 template <typename C>
|
Chris@16
|
637 void operator()(C& c) const
|
Chris@16
|
638 {
|
Chris@16
|
639 return c.pop_front();
|
Chris@16
|
640 }
|
Chris@16
|
641 };
|
Chris@16
|
642
|
Chris@16
|
643 struct push_back
|
Chris@16
|
644 {
|
Chris@16
|
645 typedef void result_type;
|
Chris@16
|
646
|
Chris@16
|
647 template <typename C, typename Arg>
|
Chris@16
|
648 void operator()(C& c, Arg const& data) const
|
Chris@16
|
649 {
|
Chris@16
|
650 return c.push_back(data);
|
Chris@16
|
651 }
|
Chris@16
|
652 };
|
Chris@16
|
653
|
Chris@16
|
654 struct push_front
|
Chris@16
|
655 {
|
Chris@16
|
656 typedef void result_type;
|
Chris@16
|
657
|
Chris@16
|
658 template <typename C, typename Arg>
|
Chris@16
|
659 void operator()(C& c, Arg const& data) const
|
Chris@16
|
660 {
|
Chris@16
|
661 return c.push_front(data);
|
Chris@16
|
662 }
|
Chris@16
|
663 };
|
Chris@16
|
664
|
Chris@16
|
665 struct rbegin
|
Chris@16
|
666 {
|
Chris@16
|
667 template <typename Sig>
|
Chris@16
|
668 struct result;
|
Chris@16
|
669
|
Chris@16
|
670 template <typename This, typename C>
|
Chris@16
|
671 struct result<This(C&)>
|
Chris@16
|
672 {
|
Chris@16
|
673 typedef typename
|
Chris@16
|
674 const_qualified_reverse_iterator_of<C>::type
|
Chris@16
|
675 type;
|
Chris@16
|
676 };
|
Chris@16
|
677
|
Chris@16
|
678 template <typename C>
|
Chris@16
|
679 typename result<rbegin(C&)>::type
|
Chris@16
|
680 operator()(C& c) const
|
Chris@16
|
681 {
|
Chris@16
|
682 return c.rbegin();
|
Chris@16
|
683 }
|
Chris@16
|
684 };
|
Chris@16
|
685
|
Chris@16
|
686 struct rend
|
Chris@16
|
687 {
|
Chris@16
|
688 template <typename Sig>
|
Chris@16
|
689 struct result;
|
Chris@16
|
690
|
Chris@16
|
691 template <typename This, typename C>
|
Chris@16
|
692 struct result<This(C&)>
|
Chris@16
|
693 {
|
Chris@16
|
694 typedef typename
|
Chris@16
|
695 const_qualified_reverse_iterator_of<C>::type
|
Chris@16
|
696 type;
|
Chris@16
|
697 };
|
Chris@16
|
698
|
Chris@16
|
699 template <typename C>
|
Chris@16
|
700 typename result<rend(C&)>::type
|
Chris@16
|
701 operator()(C& c) const
|
Chris@16
|
702 {
|
Chris@16
|
703 return c.rend();
|
Chris@16
|
704 }
|
Chris@16
|
705 };
|
Chris@16
|
706
|
Chris@16
|
707 struct reserve
|
Chris@16
|
708 {
|
Chris@16
|
709 typedef void result_type;
|
Chris@16
|
710
|
Chris@16
|
711 template <typename C, typename Arg>
|
Chris@16
|
712 void operator()(C& c, Arg const& count) const
|
Chris@16
|
713 {
|
Chris@16
|
714 c.reserve(count);
|
Chris@16
|
715 }
|
Chris@16
|
716 };
|
Chris@16
|
717
|
Chris@16
|
718 struct resize
|
Chris@16
|
719 {
|
Chris@16
|
720 typedef void result_type;
|
Chris@16
|
721
|
Chris@16
|
722 template <typename C, typename Arg1>
|
Chris@16
|
723 void operator()(C& c, Arg1 const& arg1) const
|
Chris@16
|
724 {
|
Chris@16
|
725 c.resize(arg1);
|
Chris@16
|
726 }
|
Chris@16
|
727
|
Chris@16
|
728 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
729 void operator()(C& c, Arg1 const& arg1, Arg2 const& arg2) const
|
Chris@16
|
730 {
|
Chris@16
|
731 c.resize(arg1, arg2);
|
Chris@16
|
732 }
|
Chris@16
|
733 };
|
Chris@16
|
734
|
Chris@16
|
735 struct size
|
Chris@16
|
736 {
|
Chris@16
|
737 template <typename Sig>
|
Chris@16
|
738 struct result;
|
Chris@16
|
739
|
Chris@16
|
740 template <typename This, typename C>
|
Chris@16
|
741 struct result<This(C&)>
|
Chris@16
|
742 {
|
Chris@16
|
743 typedef typename size_type_of<C>::type type;
|
Chris@16
|
744 };
|
Chris@16
|
745
|
Chris@16
|
746 template <typename C>
|
Chris@16
|
747 typename result<size(C&)>::type
|
Chris@16
|
748 operator()(C& c) const
|
Chris@16
|
749 {
|
Chris@16
|
750 return c.size();
|
Chris@16
|
751 }
|
Chris@16
|
752 };
|
Chris@16
|
753
|
Chris@16
|
754 struct splice
|
Chris@16
|
755 {
|
Chris@16
|
756 typedef void result_type;
|
Chris@16
|
757
|
Chris@16
|
758 template <typename C, typename Arg1, typename Arg2>
|
Chris@16
|
759 void operator()(C& c, Arg1 arg1, Arg2 &arg2) const
|
Chris@16
|
760 {
|
Chris@16
|
761 c.splice(arg1, arg2);
|
Chris@16
|
762 }
|
Chris@16
|
763
|
Chris@16
|
764 template <
|
Chris@16
|
765 typename C
|
Chris@16
|
766 , typename Arg1
|
Chris@16
|
767 , typename Arg2
|
Chris@16
|
768 , typename Arg3
|
Chris@16
|
769 >
|
Chris@16
|
770 void operator()(
|
Chris@16
|
771 C& c
|
Chris@16
|
772 , Arg1 arg1
|
Chris@16
|
773 , Arg2 & arg2
|
Chris@16
|
774 , Arg3 arg3
|
Chris@16
|
775 ) const
|
Chris@16
|
776 {
|
Chris@16
|
777 c.splice(arg1, arg2, arg3);
|
Chris@16
|
778 }
|
Chris@16
|
779
|
Chris@16
|
780 template <
|
Chris@16
|
781 typename C
|
Chris@16
|
782 , typename Arg1
|
Chris@16
|
783 , typename Arg2
|
Chris@16
|
784 , typename Arg3
|
Chris@16
|
785 , typename Arg4
|
Chris@16
|
786 >
|
Chris@16
|
787 void operator()(
|
Chris@16
|
788 C c
|
Chris@16
|
789 , Arg1 arg1
|
Chris@16
|
790 , Arg2 & arg2
|
Chris@16
|
791 , Arg3 arg3
|
Chris@16
|
792 , Arg4 arg4
|
Chris@16
|
793 ) const
|
Chris@16
|
794 {
|
Chris@16
|
795 c.splice(arg1, arg2, arg3, arg4);
|
Chris@16
|
796 }
|
Chris@16
|
797 };
|
Chris@16
|
798
|
Chris@16
|
799
|
Chris@16
|
800 namespace result_of
|
Chris@16
|
801 {
|
Chris@16
|
802 template <typename C>
|
Chris@16
|
803 struct value_comp
|
Chris@16
|
804 {
|
Chris@16
|
805 typedef typename value_compare_of<C>::type type;
|
Chris@16
|
806 };
|
Chris@16
|
807 }
|
Chris@16
|
808
|
Chris@16
|
809 struct value_comp
|
Chris@16
|
810 {
|
Chris@16
|
811 template <typename Sig>
|
Chris@16
|
812 struct result;
|
Chris@16
|
813
|
Chris@16
|
814 template <typename This, typename C>
|
Chris@16
|
815 struct result<This(C&)>
|
Chris@16
|
816 : result_of::value_comp<C>
|
Chris@16
|
817 {};
|
Chris@16
|
818
|
Chris@16
|
819 template <typename C>
|
Chris@16
|
820 typename result_of::value_comp<C>::type
|
Chris@16
|
821 operator()(C& c) const
|
Chris@16
|
822 {
|
Chris@16
|
823 return c.value_comp();
|
Chris@16
|
824 }
|
Chris@16
|
825 };
|
Chris@16
|
826
|
Chris@16
|
827 } // namespace stl
|
Chris@16
|
828
|
Chris@16
|
829 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
830 //
|
Chris@16
|
831 // The lazy functions themselves.
|
Chris@16
|
832 //
|
Chris@16
|
833 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
834 namespace adl_barrier
|
Chris@16
|
835 {
|
Chris@16
|
836 BOOST_PHOENIX_ADAPT_CALLABLE(assign, boost::phoenix::stl::assign, 2)
|
Chris@16
|
837 BOOST_PHOENIX_ADAPT_CALLABLE(assign, boost::phoenix::stl::assign, 3)
|
Chris@16
|
838 BOOST_PHOENIX_ADAPT_CALLABLE(assign, boost::phoenix::stl::assign, 4)
|
Chris@16
|
839 BOOST_PHOENIX_ADAPT_CALLABLE(at, ::boost::phoenix::stl::at_impl, 2)
|
Chris@16
|
840 BOOST_PHOENIX_ADAPT_CALLABLE(back, stl::back, 1)
|
Chris@16
|
841 BOOST_PHOENIX_ADAPT_CALLABLE(begin, stl::begin, 1)
|
Chris@16
|
842 BOOST_PHOENIX_ADAPT_CALLABLE(capacity, stl::capacity, 1)
|
Chris@16
|
843 BOOST_PHOENIX_ADAPT_CALLABLE(clear, stl::clear, 1)
|
Chris@16
|
844 BOOST_PHOENIX_ADAPT_CALLABLE(empty, stl::empty, 1)
|
Chris@16
|
845 BOOST_PHOENIX_ADAPT_CALLABLE(end, stl::end, 1)
|
Chris@16
|
846 BOOST_PHOENIX_ADAPT_CALLABLE(erase, stl::erase, 2)
|
Chris@16
|
847 BOOST_PHOENIX_ADAPT_CALLABLE(erase, stl::erase, 3)
|
Chris@16
|
848 BOOST_PHOENIX_ADAPT_CALLABLE(front, stl::front, 1)
|
Chris@16
|
849 BOOST_PHOENIX_ADAPT_CALLABLE(get_allocator, stl::get_allocator, 1)
|
Chris@16
|
850 BOOST_PHOENIX_ADAPT_CALLABLE(insert, stl::insert, 2)
|
Chris@16
|
851 BOOST_PHOENIX_ADAPT_CALLABLE(insert, stl::insert, 3)
|
Chris@16
|
852 BOOST_PHOENIX_ADAPT_CALLABLE(insert, stl::insert, 4)
|
Chris@16
|
853 BOOST_PHOENIX_ADAPT_CALLABLE(key_comp, stl::key_comp, 1)
|
Chris@16
|
854 BOOST_PHOENIX_ADAPT_CALLABLE(max_size, stl::max_size, 1)
|
Chris@16
|
855 BOOST_PHOENIX_ADAPT_CALLABLE(pop_back, stl::pop_back, 1)
|
Chris@16
|
856 BOOST_PHOENIX_ADAPT_CALLABLE(pop_front, stl::pop_front, 1)
|
Chris@16
|
857 BOOST_PHOENIX_ADAPT_CALLABLE(push_back, stl::push_back, 2)
|
Chris@16
|
858 BOOST_PHOENIX_ADAPT_CALLABLE(push_front, stl::push_front, 2)
|
Chris@16
|
859 BOOST_PHOENIX_ADAPT_CALLABLE(rbegin, stl::rbegin, 1)
|
Chris@16
|
860 BOOST_PHOENIX_ADAPT_CALLABLE(rend, stl::rend, 1)
|
Chris@16
|
861 BOOST_PHOENIX_ADAPT_CALLABLE(reserve, stl::reserve, 2)
|
Chris@16
|
862 BOOST_PHOENIX_ADAPT_CALLABLE(resize, stl::resize, 2)
|
Chris@16
|
863 BOOST_PHOENIX_ADAPT_CALLABLE(resize, stl::resize, 3)
|
Chris@16
|
864 BOOST_PHOENIX_ADAPT_CALLABLE(size, stl::size, 1)
|
Chris@16
|
865 BOOST_PHOENIX_ADAPT_CALLABLE(splice, stl::splice, 2)
|
Chris@16
|
866 BOOST_PHOENIX_ADAPT_CALLABLE(splice, stl::splice, 3)
|
Chris@16
|
867 BOOST_PHOENIX_ADAPT_CALLABLE(splice, stl::splice, 4)
|
Chris@16
|
868 BOOST_PHOENIX_ADAPT_CALLABLE(splice, stl::splice, 5)
|
Chris@16
|
869 BOOST_PHOENIX_ADAPT_CALLABLE(value_comp, stl::value_comp, 1)
|
Chris@16
|
870 }
|
Chris@16
|
871
|
Chris@16
|
872 using namespace phoenix::adl_barrier;
|
Chris@16
|
873 }} // namespace boost::phoenix
|
Chris@16
|
874
|
Chris@16
|
875 #endif // BOOST_PHOENIX_STL_CONTAINERS_HPP
|