Boost logo

Boost :

Subject: Re: [boost] Improving the assignment operators of various Boosttypes
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2008-09-10 14:23:53

Peter Dimov wrote:
> Michael Marcin:
> ...
>> For rvalues yes but for lvalues you need move emulation. Which can be
>> implemented in the sandbox move library as follows.
>> class foo
>> {
>> public:
>> foo();
>> foo( T t );
>> foo( boost::move_from<foo> other )
>> {
>> swap( other.source );
>> }
>> foo& operator=( foo rhs )
>> {
>> swap( rhs );
>> }
> I see what you mean now, thanks. This is, I believe, the Adobe approach
> for move emulation:
> It's based on the Adobe/Stepanov philosophy that all types are copyable,
> so it doesn't support move-only types. This takes away one motivation
> for having move. std::vector won't use adobe::move/boost::move, so this
> takes away the other motivation. What's left? :-)

Adobe may believe that all types are Regular but I have types that can't
be copied (at least not efficiently) and I disallow their copying to
prevent clients of my code from shooting themselves in the performance
foot. The move library in the boost sandbox by Daniel James, which is a
continuation of the work by others including Adobe, relaxes these
constraints and supports move only types.

I use it in some performance sensitive code or when I need/want stronger
exception safety guarantees.


Michael Marcin

Boost list run by bdawes at, gregod at, cpdaniel at, john at