Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Values

#include <boost/phoenix/core/value.hpp>

Whenever we see a constant in a partially applied function, an

expression::value<T>::type

(where T is the type of the constant) is automatically created for us. For instance:

add(arg1, 6)

Passing a second argument, 6, an expression::value<T>::type is implicitly created behind the scenes. This is also equivalent to add(arg1, val(6)).

val(v)

generates an expression::value<T>::type where T is the type of x. In most cases, there's no need to explicitly use val, but, as we'll see later on, there are situations where this is unavoidable.

Evaluating a Value

Like arguments, values are also actors. As such, values can be evaluated. Invoking a value gives the value's identity. Example:

cout << val(3)() << val("Hello World")();

prints out "3 Hello World".


PrevUpHomeNext