...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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.
// 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; };
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> { // ... };