Struct template domain

| Home | Libraries | People | FAQ | More

## Struct template domain

boost::proto::domain — For use in defining domain tags to be used with `proto::extends<>`. A domain associates an expression type with a generator, and optionally a grammar.

## Synopsis

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

    template<typename Generator = proto::default_generator,
             typename Grammar = proto::_>
    struct domain :  Generator {
      // types
      typedef Grammar   proto_grammar;
      typedef Generator proto_generator;
    };

## Description

The Generator determines how new expressions in the domain are constructed. Typically, a generator wraps all new expressions in a wrapper that imparts domain-specific behaviors to expressions within its domain. (See `proto::extends<>`.)

The Grammar determines whether a given expression is valid within the domain, and automatically disables any operator overloads which would cause an invalid expression to be created. By default, the Grammar parameter defaults to the wildcard, `proto::_` , which makes all expressions valid within the domain.

Example:

     template<typename Expr>
     struct MyExpr;

     struct MyGrammar
       : proto::or_< proto::terminal<_>, proto::plus<MyGrammar, MyGrammar> >
     {};

     // Define MyDomain, in which all expressions are
     // wrapped in MyExpr<> and only expressions that
     // conform to MyGrammar are allowed.
     struct MyDomain
       : proto::domain<proto::generator<MyExpr>, MyGrammar>
     {};

     // Use MyDomain to define MyExpr
     template<typename Expr>
     struct MyExpr
       : proto::extends<Expr, MyExpr<Expr>, MyDomain>
     {
         // ...
     };