![]() |
Home | Libraries | People | FAQ | More |
#include <boost/phoenix/stl/algorithm.hpp>
The algorithm module provides wrappers for the standard algorithms in the
<algorithm>
and <numeric>
headers.
The algorithms are divided into the categories iteration, transformation and querying, modeling the Boost.MPL library. The different algorithm classes can be included using the headers:
#include <boost/phoenix/stl/algorithm/iteration.hpp> #include <boost/phoenix/stl/algorithm/transformation.hpp> #include <boost/phoenix/stl/algorithm/querying.hpp>
The functions of the algorithm module take ranges as arguments where appropriate. This is different to the standard library, but easy enough to pick up. Ranges are described in detail in the Boost.Range library.
For example, using the standard copy algorithm to copy between 2 arrays:
int array[] = {1, 2, 3}; int output[3]; std::copy(array, array + 3, output); // We have to provide iterators // to both the start and end of array
The analogous code using the phoenix algorithm module is:
int array[] = {1, 2, 3}; int output[3]; copy(arg1, arg2)(array, output); // Notice only 2 arguments, the end of // array is established automatically
The Boost.Range library provides support for standard containers, strings and arrays, and can be extended to support additional types.
The following tables describe the different categories of algorithms, and their semantics.
Arguments in brackets denote optional parameters.
Table 1.6. Iteration Algorithms
Function |
stl Semantics |
---|---|
|
|
|
|
Table 1.7. Querying Algorithms
Function |
stl Semantics |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Table 1.8. Transformation Algorithms
Function |
stl Semantics |
Language Standards |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Until C++17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|