[cfe-dev] Specializing std::swap
james.dennett at gmail.com
Wed May 22 19:47:06 PDT 2013
On Wed, May 22, 2013 at 7:14 PM, Aleksandar Fabijanic <aleskx at gmail.com>wrote:
> It was stated in this bug report
> that specializing swap for non-std types in std namespace, although
> legal, is considered fragile. It is not entirely clear from the
> response why is that so.
> Can someone shed some light on this?
I'm not sure this is topical for cfe-dev, as it's just a question about C++.
C++ doesn't have partial specialization for templates, so it's not possible
to define a std::swap for a user-define template. You could write an
overload, except that it's not permitted to add overloads to namespace std.
On the bright side, ADL means that it's not necessary to put those in
namespace std anyway, so long as people use swap properly (such that ADL is
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev