]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | The MPL provides a broad range of fundamental algorithms aimed to | |
3 | satisfy the majority of sequential compile-time data processing | |
4 | needs. The algorithms include compile-time counterparts | |
5 | of many of the STL algorithms, iteration algorithms borrowed from | |
6 | functional programming languages, and more. | |
7 | ||
8 | Unlike the algorithms in the C++ Standard Library, which operate on | |
9 | implict *iterator ranges*, the majority of MPL counterparts take | |
10 | and return *sequences*. This derivation is not dictated by the | |
11 | functional nature of C++ compile-time computations per se, but | |
12 | rather by a desire to improve general usability of the library, | |
13 | making programming with compile-time data structures as enjoyable | |
14 | as possible. | |
15 | ||
16 | .. This can be seen as a further generalization and extension of | |
17 | the STL's conceptual framework. | |
18 | ||
19 | In the spirit of the STL, MPL algorithms are *generic*, meaning | |
20 | that they are not tied to particular sequence class | |
21 | implementations, and can operate on a wide range of arguments as | |
22 | long as they satisfy the documented requirements. The requirements | |
23 | are formulated in terms of concepts. Under the hood, | |
24 | algorithms are decoupled from concrete sequence | |
25 | implementations by operating on |iterators|. | |
26 | ||
27 | All MPL algorithms can be sorted into three | |
28 | major categories: iteration algorithms, querying algorithms, and | |
29 | transformation algorithms. The transformation algorithms introduce | |
30 | an associated |Inserter| concept, a rough equivalent for the notion of | |
31 | |Output Iterator| in the Standard Library. Moreover, every | |
32 | transformation algorithm provides a ``reverse_`` counterpart, | |
33 | allowing for a wider range of efficient transformations |--| a | |
34 | common functionality documented by the |Reversible Algorithm| | |
35 | concept. | |
36 | ||
37 | ||
38 | .. |Output Iterator| replace:: `Output Iterator <http://www.sgi.com/tech/stl/OutputIterator.html>`__ | |
39 | .. |sequence algorithms| replace:: `sequence algorithms`_ | |
40 | .. _`sequence algorithms`: `Algorithms`_ | |
41 | ||
42 | ||
43 |