[proto]are there 2 ways to define generators?

In: html/boost_proto/user_s_guide/extending_proto.html there's: <--------- cut here ----------- namespace boost { namespace proto { // A specialization of generate<> that causes expression in the // calculator_domain to be wrapped in the calculator<> wrapper. template< typename Expr > struct generate< calculator_domain, Expr > { typedef calculator< Expr > type; static type make( Expr const & expr ) { return type( expr ); } }; }} This instructs Proto to wrap all expressions in the calculator_domain in the calculator<> wrapper.
--------- cut here ----------- OTOH, in:
libs/xpressive/proto/example/calc3.cpp there's: <--------- cut here ----------- // Tell proto how to generate expressions in the calculator_domain struct calculator_domain : proto::domain<proto::generator<calculator_expression> > {};
--------- cut here -----------
which suggests to me that there's 2 different ways to wrap expressions in a particular domain. Is that right? If so, what are the advantages of one over the other method?

Larry Evans wrote:
In:
html/boost_proto/user_s_guide/extending_proto.html
there's: <--------- cut here ----------- namespace boost { namespace proto { // A specialization of generate<> that causes expression in the // calculator_domain to be wrapped in the calculator<> wrapper. template< typename Expr > struct generate< calculator_domain, Expr > { typedef calculator< Expr > type;
static type make( Expr const & expr ) { return type( expr ); } }; }}
This instructs Proto to wrap all expressions in the calculator_domain in the calculator<> wrapper.
You are looking at out of date documentation. Get the latest docs -- this has been changed. -- Eric Niebler Boost Consulting www.boost-consulting.com
participants (2)
-
Eric Niebler
-
Larry Evans