Topic: std::swap calling member-swap? (was: std::swap


Author: Marc Mutz <marc.mutz@kdab.com>
Date: Thu, 2 Feb 2017 11:27:20 +0100
Raw View
Hi,

I don't know the state of the default-swap proposal, but this here seems
orthogonal, anyway:

The following is intentionally kept very vague:

I was wondering whether std::swap could not prefer to call a member-swap where
it exists, and only otherwise perform the default 3-move-assignment that it
has since C++11.

A nice benefit of this would be that all the std::swap
specialisations/overloads for (most) containers would go away, because they
provide member-swap functions already.

This would also mitigate the source-incompatibility described in this thread,
as users could add member-swaps to their non-movable/non-copyable classes.

Thanks,
Marc

--
Marc Mutz <marc.mutz@kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts

.