[RFA] Removing const from std::swap
Gabriel Dos Reis
Thu May 19 16:10:00 GMT 2005
Paolo Carlini <firstname.lastname@example.org> writes:
| Hi everyone,
| some time ago, in an overzealous (it seems ;) series of const- tweaks to
| the algorithms, I touched std::swap too, adding a const to the temporary
| template<typename _Tp>
| inline void
| swap(_Tp& __a, _Tp& __b)
| // concept requirements
| const _Tp __tmp = __a;
| __a = __b;
| __b = __tmp;
| This is strictly speaking absolutely legal, as the concept check also
| demonstrates, but now people on the c++.moderated list, Howard Hinnant
| for example, believe that this is "overly pedantic" ;) ... Shall I
| remove it?
I'll look at it differently: Does the const buy us anything? If not,
it should be removed.
| If we keep it, auto_ptrs cannot be swapped, as an extension,
I do not follow here.
More information about the Libstdc++