Boost logo

Boost :

From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2008-04-08 16:22:22


On Mon, Apr 7, 2008 at 2:46 PM, shunsuke <pstade.mb_at_[hidden]> wrote:
> Eric Niebler wrote:
> > What I'm saying is that, in C++03, polymorphic function objects are
> > broken, so we need the runtime equivalent of a metafunction class ... a
> > generator for monomorphic function objects. Call it a function class:
> >
> > struct fun_class
> > {
> > template<typename A>
> > struct apply
> > {
> > typedef ... result_type;
> > result_type operator()(
> > typedef add_const_ref<A>::type a
> > ) const
> > {
> > return ...;
> > }
> > };
> > };
> >
> > Now both the return type calculation *and* the operator() have access to
> > *all* the information about the arguments, even their lvalue/rvalue-ness.
>
> After all, if you need "overload on rvalueness" in C++03,
> some workaround is needed.
>
> BTW, this doesn't need a new concept:
> foo(i, boost::rval(3));
> I don't like it of course, though. :-)

Good point and maybe this is what I didn't understand about using
reference wrappers. In C++98 (and 03?), since rvalues and lvalues both
bind to const refs, you can't really tell them apart without some
convention (such as Shunsuke's above or reference wrappers)
allowing/requiring the caller to specify which is intended. I don't
see the motivation for Proto to attempt to distinguish rvalues and
lvalues in C++03. Is there some dangling reference issue that I'm
missing?

BTW, Eric, congrats on Proto's acceptance! If I had written a review
it would have been positive, but I've been out of it for many moons.
;-)

Daniel


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