Boost logo

Boost :

From: Joel de Guzman (djowel_at_[hidden])
Date: 2002-12-20 17:52:36


----- Original Message -----
From: "Peter Dimov" <pdimov_at_[hidden]>

> From: "Joel de Guzman" <djowel_at_[hidden]>
> [...]
> > The condition is expected to be a functor that returns
> > a boolean condition. I was hoping that I can use the
> > ref(b) as a functor such that I can write:
> >
> > bool b;
> >
> > if_p(ref(b))
> > [
> > parse_this
> > ]
>
> Not a good idea. In lambda terms the above is var(b), not ref(b). We've been
> using ref(x) to mean "just like x", i.e. ref(b)() means b(). One day we
> might even get that core change that would enable
> reference_wrapper<T>::operator T& to be considered in a ref(f)() expression;
> for now, we "fake" it in bind, function, etc.

I beg to disagree. I do not see that as reasonable. The use of var(b)
will bring in tons of scaffolding. This is the main reason why I want to
request for the operator(). I've struggled hard to keep the core
of Spirit small enough to do micro parsing. I do not wish to force the
user to use lambda or phoenix, bind nor function just to do such a trivial
operation that can be accomplished by a one-liner in ref(x).

Historically, Spirit had a ref(x) that does that identity thingy. It has been
made obsolete in favor of boost::ref. I might have to bring it back to
life if my request cannot be granted. I see no other way to accomplish
ref(x)() for micro-parsing tasks.

Regards,
Joel de Guzman
joel_at_[hidden]
http://www.boost-consulting.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk