Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Struct template external_transforms

boost::proto::external_transforms — A map from grammars to transforms, used as a way to externally associate transforms.

Synopsis

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

template<typename... When> 
struct external_transforms {
  // types
  typedef  ;  // For exposition only.

  // member classes/structs/unions
  template<typename Grammar> 
  struct when :
     proto::otherwise< typename mpl::at< map_type, Grammar >::type >
  {
  };
};

Description

It is sometimes desirable to define a grammar that can be customized with different sets of transforms. To do that, where you would normally specify a transform within a grammar, you can instead put proto::external_transform; for example: proto::when< some_grammar, proto::external_transform >. Then, when invoking the grammar, you can pass an approriately-defined instance of proto::external_transforms as the Data parameter. When an expression matches some_grammar, Proto will look up the approprite transform in the Data parameter using some_grammar as a key.

proto::terminal<proto::terminal<proto::or_<
        // The next two grammar rules are customization points.
        // The associated transforms are specified externally
        // using external_transforms below.
        proto::when< proto::external_transform >
      , proto::when< proto::external_transform >
      , proto::when<
            proto::plus< proto::fold< proto::_, proto::when<proto::_value)>
      , proto::when<proto::_value)>
    >
{};

// ...

proto::literal<proto::literal<


PrevUpHomeNext