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 the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Struct template switch_

boost::proto::switch_ — For matching one of a set of alternate grammars, which are looked up based on an 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> 
struct switch_ :  proto::transform<switch_<Cases> > {
  // types
  typedef switch_ proto_grammar;

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

Description

An expression type E matches proto::switch_<C> if E matches C::case_<E::proto_tag>.

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


PrevUpHomeNext