Boost logo

Boost :

Subject: Re: [boost] noncopyable && C++11
From: Nathan Ridge (zeratul976_at_[hidden])
Date: 2012-07-06 13:21:52


> Hmm, I see this was discussed before:
> http://lists.boost.org/boost-users/2011/07/69621.php
>
> Which I failed to find first time I searched.
>
> There is still the case where I want to prevent copying (but allow
> moving), and boost::noncopyable was what I used before move semantics.
>
> I guess we could have:
>
> class moveonly
> {
> protected:
> moveonly() = default;
> moveonly(moveonly&&) = default;
> moveonly& operator=(moveonly&&) = default;
> // implicit
> // moveonly(moveonly const&) = delete;
> // moveonly& operator=(moveonly const&) = delete;
> };
>
> So that there is an expressive and concise form of "I want this to have
> default move semantics without being copyable".

I believe the conclusion of that thread was to simply declare a defaulted
move constructor in your derived class. Its presence will inhibit the
generation of a copy constructor (on conformant compilers) and so your
class will be moveable but not copyable.

Regards,
Nate
                                               


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