| Home | Libraries | People | FAQ | More

#### Container

    #include <boost/phoenix/stl/container.hpp>

The container module predefines a set of lazy functions that work on STL containers. These functions provide a mechanism for the lazy evaluation of the public member functions of the STL containers. The lazy functions are thin wrappers that simply forward to their respective counterparts in the STL library.

Lazy functions are provided for all of the member functions of the following containers:

- deque
- list
- map
- multimap
- vector

Indeed, should your class have member functions with the same names and signatures as those listed below, then it will automatically be supported. To summarize, lazy functions are provided for member functions:

- assign
- at
- back
- begin
- capacity
- clear
- empty
- end
- erase
- front
- get_allocator
- insert
- key_comp
- max_size
- pop_back
- pop_front
- push_back
- push_front
- rbegin
- rend
- reserve
- resize
- size
- splice
- value_comp

The lazy functions' names are the same as the corresponding member function. The difference is that the lazy functions are free functions and therefore does not use the member "dot" syntax.

Table 1.4. Sample usage

"Normal" version | "Lazy" version
--- | ---
`my_vector.at(5)` | `at(arg1, 5)`
`my_list.size()` | `size(arg1)`
`my_vector1.swap(my_vector2)` | `swap(arg1, arg2)`

Notice that member functions with names that clash with stl algorithms are absent. This will be provided in Phoenix's algorithm module.

No support is provided here for lazy versions of `operator+=`, `operator[]` etc. Such operators are not specific to STL containers and lazy versions can therefore be found in operators.

The following table describes the container functions and their semantics.

Table 1.5. Lazy STL Container Functions

Function | Semantics
--- | ---
`assign(c, a[, b, c])` | `c.assign(a[, b, c])`
`at(c, i)` | `c.at(i)`
`back(c)` | `c.back()`
`begin(c)` | `c.begin()`
`capacity(c)` | `c.capacity()`
`clear(c)` | `c.clear()`
`empty(c)` | `c.empty()`
`end(c)` | `c.end()`
`erase(c, a[, b])` | `c.erase(a[, b])`
`front(c)` | `c.front()`
`get_allocator(c)` | `c.get_allocator()`
`insert(c, a[, b, c])` | `c.insert(a[, b, c])`
`key_comp(c)` | `c.key_comp()`
`max_size(c)` | `c.max_size()`
`pop_back(c)` | `c.pop_back()`
`pop_front(c)` | `c.pop_front()`
`push_back(c, d)` | `c.push_back(d)`
`push_front(c, d)` | `c.push_front(d)`
`pop_front(c)` | `c.pop_front()`
`rbegin(c)` | `c.rbegin()`
`rend(c)` | `c.rend()`
`reserve(c, n)` | `c.reserve(n)`
`resize(c, a[, b])` | `c.resize(a[, b])`
`size(c)` | `c.size()`
`splice(c, a[, b, c, d])` | `c.splice(a[, b, c, d])`
`value_comp(c)` | `c.value_comp()`