Boost logo

Boost :

Subject: Re: [boost] C++03 unique_ptr emulation
From: David Abrahams (dave_at_[hidden])
Date: 2009-01-09 15:29:46

on Fri Jan 09 2009, Ion Gaztañaga <> wrote:

> David Abrahams wrote:
>> So you're saying, in other words, that "move(x)" really means "you have
>> permission to move x" but the one I proposed would mean "move it, now."
>> OK, good point.
>> So what about this horrible little proposal?
>> template <class T>
>> struct rv<T> : T
>> {
>> private:
>> rv();
>> ~rv();
>> rv(rv const&);
>> void operator=(rv const&);
>> };
>> template <class T>
>> boost::enable_if<is_class<T>, rv<T>&>
>> move(T& x)
>> {
>> return static_cast<rv<T>& >(x);
>> }
>> Does that solve any problems?
> How can that work? What would you need to add to T? Disable non-const
> copy constructor?

Well, I haven't thought this through deeply (nor really tested
anything), but the idea is that movable types would have a stealing
conversion from rv<T>& but non-movable types should just use the copy
ctor that slices off the non-existent derived class.

>> Yeah, I know it's not theoretically portable, but it should be portable
>> in practice. Especially when it comes to emulating language features, I
>> care less and less about the letter of the law :-)
> I would be really interested in this proposal.

I'm not even sure if it addresses the problems you're working on, but
it's a thought.

Dave Abrahams
BoostPro Computing

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