Subject: Re: [boost] rvalue ref best practices?
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2012-06-09 18:58:49
On Jun 9, 2012, at 6:44 PM, Daniel Larimer wrote:
> In my particular case I am passing 'messages' around and they only ever exist in one place at a time. I want the compiler to tell me when I try to make a copy. The effect is the same as using unique_ptr<Message> except that Message has value semantics and there is no 'extra' heap allocation for Message which is essentially a pointer to the real data.
Perhaps in your particular case a move-only message, or a message with an explicit copy member is a good idea. You might be willing to sacrifice usability with generic-copy-algorithms for this class to get the benefit of being assured that copies either can't happen or are suitably rare.
But I wouldn't recommend an explicit copy for more general purpose types, because a general purpose type has to be usable in such a wide variety use cases. Obviously though we do have general purpose move-only types.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk