Boost logo

Boost :

Subject: Re: [boost] [move] new rvalue reference emulation
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-04-05 10:44:02

On Tue, Apr 5, 2011 at 7:37 AM, Dave Abrahams <dave_at_[hidden]> wrote:

> At Mon, 4 Apr 2011 22:14:29 -0700,
> Jeffrey Lee Hellrung, Jr. wrote:
> >
> > I also forgot to mention that (obviously) this precludes polymorphic
> return
> > types :( At least, I don't see how they can be supported...
> Sorry, can you show an example of what's precluded, using C++0x notation?

There's no way to make the return type dependent on the argument type, since
the argument type has been erased:

// C++0x, with rvalue references
template< class T >
typename result_of::some_fn<T>::type // result type is polymorphic; it
depends on the argument type
some_fn(T&& x);

// C++03, with emulated "typeless" rvalue reference
typename result_of::some_fn< /* what goes here? */ >::type // result type
cannot depend on the argument type, since we don't know the argument type!
some_fn(generic_rv< ???, ??? > x);

Perhaps my use of the term "polymorphic" here is wrong; if so, let me know!

- Jeff

Boost list run by bdawes at, gregod at, cpdaniel at, john at