Boost logo

Boost :

From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-07-31 16:27:40


Daniel James wrote:
> 2008/7/31 Michael Marcin <mike.marcin_at_[hidden]>:
>
>> However the documentation says that objects have to model the Regular
>> concept in order to model the Movable concept. This seems unfortunate as
>> Regular puts a lot of requirements on types that don't seem necessary to
>> gain moving. It requires Assignable which requires a copy constructor and it
>> requires EqualityComparable which seems unnecessary.
>
> Sorry, the documentation is out of date, I haven't updated it for the
> changes I've made. The library does supports noncopyable types. If you
> can decipher it there is an example in the unit tests (in y.hpp - I'll
> probably rename that file). You have to implement it a little
> differently to your normal noncopyable type. The signature is
> something like:

Fantastic. I sort of figured it does since I'm using them just wanted to
make sure it was a feature and not a bug.

>
> class noncopyable
> {
> // Private constructor to make it noncopyable.
> // Note that it's a non-const reference
> noncopyable(noncopyable&);
> public:
> noncopyable();
> ~noncopyable();
> noncopyable(boost::move_from<noncopyable>); // Move constructor
> noncopyable& operator=(noncopyable); // Move assignment
> operator boost::move_from<noncopyable>() {
> return boost::move_from<noncopyable>(*const_cast<noncopyable*>(this));
> }
> };

The implicit conversion to move_from seems very dangerous to me.

>
> I should warn you that the library will probably change to support
> other types and hopefully rvalue references. I'll be resuming work on
> it soon after this release is done.
>

I'm looking forward to it.

Thanks,

Michael Marcin


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