[Proto] Using custom function tag in the simplified calalble context
I've defined some custom tag for user specific function like :
struct conj_tag {};
I have made the following expression builder using make_expr :
template<class X>
typename proto::result_of::make_expr< conj_tag, X const &>::type
conj( X const& x )
{
return proto::make_expr
Joel Falcou wrote:
I've defined some custom tag for user specific function like : struct conj_tag {};
I have made the following expression builder using make_expr :
template<class X> typename proto::result_of::make_expr< conj_tag, X const &>::type conj( X const& x ) { return proto::make_expr
(boost::cref(x)); } And I match this function using the following grammar rule : struct my_grammar : or_< // some terminal , bp::function< bp::terminal
, my_grammar> > {};
That's not right. Your conj() function is returning a unary expression
with a conj_tag tag type. Your grammar is trying to match a binary
expression with a proto::tag::function tag type. Your grammar should be:
proto::unary_expr
Now, how should I overload operator() of a callable_context to match this special tag ?
In your context, you should have an overloaded operator() like this: template<typename Expr> some-return-type operator()(conj_tag, Expr const &expr) const { ... } HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com
Eric Niebler a écrit :
That's not right. Your conj() function is returning a unary expression with a conj_tag tag type. Your grammar is trying to match a binary expression with a proto::tag::function tag type. Your grammar should be:
proto::unary_expr
Ah, this explains another oddities then. Ok, I think i got side-tracked by some other example I read in the old doc.
In your context, you should have an overloaded operator() like this:
template<typename Expr> some-return-type operator()(conj_tag, Expr const &expr) const { ... }
perfect. Thanks again for spending time answering my silly questions ;) -- ___________________________________________ Joel Falcou - Assistant Professor PARALL Team - LRI - Universite Paris Sud XI Tel : (+33)1 69 15 66 35
Following some of the discussion regarding phoenix made me want to find out more about proto. After poking around, I found proto package in the trunk on my machine. I updated my local trunk for these directories. I found documentation for proto in *.qbk and Boost Book XML files. How do I browse this documentation? or where do I get the html documentation for this package? Robert Ramey
Robert Ramey wrote:
Following some of the discussion regarding phoenix made me want to find out more about proto.
After poking around, I found proto package in the trunk on my machine. I updated my local trunk for these directories.
I found documentation for proto in *.qbk and Boost Book XML files. How do I browse this documentation? or where do I get the html documentation for this package?
Hi Robert, I keep an up-to-date copy of Proto's HTML docs at http://boost-sandbox.sf.net/libs/proto. HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com
participants (4)
-
Eric Niebler
-
Eric Niebler
-
Joel Falcou
-
Robert Ramey