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