Boost logo

Boost :

Subject: Re: [boost] C++03 unique_ptr emulation
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-09 16:54:01


----- Original Message -----
From: "Ion Gaztañaga" <igaztanaga_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, January 09, 2009 9:15 PM
Subject: Re: [boost] C++03 unique_ptr emulation

>
> 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?
>
>> 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.

Attaced it is your move_test adapted to the new proposal. It works on more cases than before.
Define ALT1to come back to the preceding definition of move and rv.

Thanks,
Vicente



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