|
Boost Users : |
Subject: Re: [Boost-users] [Proto] Using custom function tag in the simplified calalble context
From: Eric Niebler (eric_at_[hidden])
Date: 2008-10-04 11:14:51
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<conj_tag>(boost::cref(x));
> }
>
> And I match this function using the following grammar rule :
> struct my_grammar : or_< // some terminal
> , bp::function<
> bp::terminal<conj_tag>, 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<conj_tag, my_grammar>
> 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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net