Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::proto::when< Grammar, PrimitiveTransform > Struct Template Reference

A grammar element and a PrimitiveTransform that associates a transform with the grammar. More...

#include <when.hpp>

Inherits PrimitiveTransform.

Collaboration diagram for boost::proto::when< Grammar, PrimitiveTransform >:

Public Types

typedef Grammar first
 
typedef PrimitiveTransform second
 
typedef Grammar::proto_grammar proto_grammar
 

Detailed Description

template<typename Grammar, typename PrimitiveTransform>
struct boost::proto::when< Grammar, PrimitiveTransform >

A grammar element and a PrimitiveTransform that associates a transform with the grammar.

Use when<> to override a grammar's default transform with a custom transform. It is for used when composing larger transforms by associating smaller transforms with individual rules in your grammar, 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
: or_<
when<terminal<_>, mpl::next<_state>()>
, otherwise<fold<_, _state, CountLeaves> >
>
{};

In when<G, T>, when T is a class type it is a PrimitiveTransform and the following equivalencies hold:

boost::result_of<when<G,T>(E,S,V)>::type is the same as boost::result_of<T(E,S,V)>::type.

when<G,T>()(e,s,d) is the same as T()(e,s,d).

Member Typedef Documentation

template<typename Grammar, typename PrimitiveTransform>
typedef Grammar boost::proto::when< Grammar, PrimitiveTransform >::first
template<typename Grammar, typename PrimitiveTransform>
typedef Grammar::proto_grammar boost::proto::when< Grammar, PrimitiveTransform >::proto_grammar
template<typename Grammar, typename PrimitiveTransform>
typedef PrimitiveTransform boost::proto::when< Grammar, PrimitiveTransform >::second

The documentation for this struct was generated from the following files: