...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Care and attention to detail was given, painstakingly, to the design and implementation of Phoenix.
The library is organized in four layers:
The modules are orthogonal, with no cyclic dependencies. Lower layers do not depend on higher layers. Modules in a layer do not depend on other modules in the same layer. This means, for example, that Bind can be completely discarded if it is not required; or one could perhaps take out Operator and Statement and just use Function, which may be desirable in a pure FP application.
The library has grown from the original Phoenix but still comprises only header files. There are no object files to link against.
The lowest two layers comprise the core.
The Actor
is the main concept behind the library. Lazy functions are abstracted as actors.
Terminals provide the basic building blocks of functionality within Phoenix. Expressions are used to combine these terminals together to provide more powerful functionality.
Expressions are composed of zero or more actors. Each actor in a composite can again be another expression.
Table 1.2. Modules
Module |
Description |
---|---|
Function |
Lazy functions support (e.g. |
Operator |
Lazy operators support (e.g. |
Statement |
Lazy statements (e.g. |
Object |
Lazy casts (e.g. |
Scope |
Support for scopes, local variables and lambda-lambda |
Bind |
Lazy functions from free functions, member functions or member variables. |
STL Container |
Set of predefined "lazy" functions that work on STL containers
and sequences (e.g. |
STL Algorithm |
Set of predefined "lazy" versions of the STL algorithms
(e.g. |
Each module is defined in a header file with the same name. For example, the
core module is defined in <boost/phoenix/core.hpp>
.
Table 1.3. Includes
Module |
File |
---|---|
Core |
|
Function |
|
Operator |
|
Statement |
|
Object |
|
Scope |
|
Bind |
|
Container |
|
Algorithm |
|
Finer grained include files are available per feature; see the succeeding sections.