Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template otherwise

boost::proto::otherwise — Syntactic sugar for proto::when< proto::_, Fun >, for use in grammars to handle all the cases not yet handled.

Synopsis

// In header: <boost/proto/transform/when.hpp>

template<typename Fun> 
struct otherwise :  proto::when< proto::_, Fun > {
};

Description

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> >
  >
{};


PrevUpHomeNext