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 an old version of boost. Click here for the latest version's documentation home page.
PrevUpHomeNext

Struct template when<Grammar, R(A...)>

boost::proto::when<Grammar, R(A...)> — A grammar element and a PrimitiveTransform that associates a transform with the grammar.

Synopsis

template<typename Grammar, typename R, typename... A> 
struct when<Grammar, R(A...)> :  proto::transform< when<Grammar, R(A...)> > {
  // types
  typedef typenme Grammar::proto_base_expr proto_base_expr;
  template<typename Expr, typename State, typename Data> 
  struct impl :  proto::transform_impl< Expr, State, Data > {
    // types
    typedef proto::call<R(A...)>                                            call_;        // For exposition only
    typedef proto::make<R(A...)>                                            make_;        // For exposition only
    typedef typename mpl::if_<proto::is_callable<R>,call_,make_>::type      which;        // For exposition only
    typedef typename which::template impl< Expr, State, Data >::result_type result_type;

    // public member functions
    result_type operator()(typename impl::expr_param, 
                           typename impl::state_param, 
                           typename impl::data_param) const;
  };
};

Description

Use proto::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.

The when<G, R(A...)> form accepts either a CallableTransform or an ObjectTransform as its second parameter. proto::when<> uses proto::is_callable<R>::value to distinguish between the two, and uses proto::call<> to evaluate CallableTransforms and proto::make<> to evaluate ObjectTransforms.


PrevUpHomeNext