Boost logo

Boost :

Subject: Re: [boost] C++03 unique_ptr emulation
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-01-09 15:12:36


David Abrahams wrote:
>> This is needed if boost::move returns boost::detail::rv<T> instead of
>> T.
>
> But boost::move should return T.

Why? && is a reference, boost::move could return a pseudo-reference.

>> Returning T from move() avoids the need of explicitly specify
>> movable() when passing arguments by value but makes forwarding really
>> hard.
>
> I don't see how it impacts forwarding.

How can you implement a "forwarding"-like function like this without
penalyzing non-movable types?

template<class T1, class T2, class T3, ...>
emplace(...)

if move() returns a pseudo-reference, this almost works easily
(non-const references are forwarded as const-references but this might
be acceptable for an emulation:

template<class T1, class T2, ...>
emplace(const T1 &t1, const T1 &t2, ...){
    void *ptr = allocate();
    new(ptr)(t1, t2, ....)
}

>> On the other hand returning rv<T> makes forwarding easy
>
> I don't see that either. You'll deduce rv<T> in a generic forwarding
> signature instead of T, which has a lot of potential to screw thinigs
> up.

See above.

> Still lost.

I hope it's more clear now,

Ion


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