Boost logo

Boost Users :

Subject: Re: [Boost-users] noncopyable and move semantics
From: Nevin Liber (nevin_at_[hidden])
Date: 2011-07-29 02:42:14


On 28 July 2011 18:12, Nathan Ridge <zeratul976_at_[hidden]> wrote:

> On the other hand, I think that is the most common case:
>
> - you don't want to allow copying, either because it doesn't make sense
> semantically, or because it's too inefficient
> - you want to allow moving so that e.g. you can store the object in a
> container without having to add a layer of indirection such as unique_ptr
> - the default move constructor does the correct thing (just like in
> most cases, the default copy constructor does the correct thing)
>

In most (if not all) of the above cases, the rules of C++0x will already do
the right thing. If I want to allow moving but not copying, all I have to
do is declare a move constructor. What exactly do I need the noise of an
extra header and deriving from some boost::moveableonly class for?

It's more for the readers of my code to learn with no semantic benefit, and
given that they have to learn the C++0x rules anyway, I probably would never
use such a class.

boost::noncopyable bought us something in C++03. I really don't see what
boost::noncopyable or some boost::moveableonly class buys us in C++0x.

-- 
Nevin ":-)" Liber  <mailto:nevin_at_[hidden]>  (847) 691-1404


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net