|
Boost : |
Subject: Re: [boost] [utility] [swap] How about Boost.Move?
From: Dave Abrahams (dave_at_[hidden])
Date: 2013-08-03 16:54:48
on Tue Jul 30 2013, Joseph Gauterin <joseph.gauterin-AT-googlemail.com> wrote:
>>
>> 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
That's not true. Specializing has at least two serious technical
disadvantages:
1. Doesn't work for templates because you can't partially specialize
functions
2. Interacts badly with overloads: overload resolution doesn't consider
specializations; they're merely implementation substitutions that are
made *after* the overload to call has been selected.
-- Dave Abrahams
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk