![]() |
Home | Libraries | People | FAQ | More |
boost::proto::otherwise —
Syntactic sugar for proto::when< proto::_, Fun >,
for use in grammars to handle all the cases not yet handled.
template<typename Fun> struct otherwise : proto::when< proto::_, Fun > { };
Use proto::otherwise<T> in your grammars as a synonym for
proto::when< proto::_, Fun >
as in the following transform which counts the number of terminals in an expression.
// Count the terminals in an expression tree.
// Must be invoked with initial state == mpl::int_<0>().
struct CountLeaves :
proto::or_<
proto::when<proto::terminal<proto::_>, mpl::next<proto::_state>()>,
proto::otherwise<proto::fold<proto::_, proto::_state, CountLeaves> >
>
{};