Boost logo

Boost :

Subject: Re: [boost] [utility] [swap] How about Boost.Move?
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2013-07-30 05:23:59


>
> The recommended way is to overload swap for your type, not specialize
> std::swap. As long as that case still works, the rest might be acceptable...

At the time boost::swap was created, my motivating use case involved use of
multiple 3rd party libraries. Some provided swap through ADL, others by
specialising std::swap. Both techniques are legal and there's no clear
technical advantage to either (I prefer the ADL solution since I find code
that opens the std namespace to look 'wrong' - but that's a matter of
taste).

I'm not at all keen on users upgrading from boost 1.38.0-1.54.0 to a newer
version and finding that their O(1) swap has turned into 3 calls to an O(n)
copy because the author of a library they depend on used a technique which
has since fallen out favour due to a consensus forming around the
alternative.

Joe

On Tue, Jul 30, 2013 at 8:51 AM, Marc Glisse <marc.glisse_at_[hidden]> wrote:

> On Mon, 29 Jul 2013, Joseph Gauterin wrote:
>
> 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?
>>
>
> The recommended way is to overload swap for your type, not specialize
> std::swap. As long as that case still works, the rest might be acceptable...
>
> --
> Marc Glisse
>
>
> ______________________________**_________________
> Unsubscribe & other changes: http://lists.boost.org/**
> mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>
>


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