Boost logo

Boost :

Subject: Re: [boost] [utility] [swap] How about Boost.Move?
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2013-07-30 03:23:58


2013/7/29 Joseph Gauterin <joseph.gauterin_at_[hidden]>

> Given a user define types that specializes std::swap but isn't moveable (a
> reasonable scenario for C++03 code still being compiled with a C++03
> compiler), wouldn't this change result in 3 copies instead of a single call
> to the specialized std:swap?
>

You are right! I've tried to apply patch and run regression tests on my own
PC. Different versions of patch break different use cases: std::swap
specialization in std namespace, ADL for the users namespaces, ADL for
boost namespace...

Looks like the only solution that does not break existing code would be to
specialize the boost::swap for ::boost::rv<T> and advice users to write
constructions like this:

boost::swap(boost::move(object1), boost::move(object2));

But that's an ugly solution. Or am I missing something and there is a
better way to make the boost::swap function work with emulated rvalue
references?

-- 
Best regards,
Antony Polukhin

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