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

PrevUpHomeNext

Struct template switch_

boost::proto::switch_ — For matching one of a set of alternate grammars, which are looked up based on the result type of the transform passed in second template parameter. If no transform is passed, the default one is proto::tag_of<proto::_>() so the default matching is based on the expression's tag type. When used as a transform, proto::switch_<> applies the transform associated with the sub-grammar that matches the expression.

Synopsis

// In header: <boost/proto/matches.hpp>

template<typename Cases, typename Transform> 
struct switch_ :  proto::transform<switch_<Cases, Transform> > {
  // types
  typedef switch_ proto_grammar;

  // member classes/structs/unions
  template<typename Expr, typename State, typename Data> 
  struct impl :  
    Cases::template case_<
      typename when<_, Transform>::template impl<Expr, State, Data>::result_type 
    >::template impl<Expr, State, Data>
  {
  };
};

Description

An expression type E matches proto::switch_<C,T> if E matches C::case_<boost::result_of<proto::when<proto::_,T>(E)>::type>.

When applying proto::switch_<C,T> as a transform with an expression e of type E, state s of type S and data d of type D, it is equivalent to C::case_<boost::result_of<proto::when<proto::_,T>(E,S,D)>::type>()(e, s, d).


PrevUpHomeNext