This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFA] Removing const from std::swap
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: 19 May 2005 19:18:11 +0200
- Subject: Re: [RFA] Removing const from std::swap
- References: <428CA0D9.6050807@suse.de>
Paolo Carlini <pcarlini@suse.de> 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
| __tmp:
|
| template<typename _Tp>
| inline void
| swap(_Tp& __a, _Tp& __b)
| {
| // concept requirements
| __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
|
| 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,
| indeed...
I do not follow here.
-- Gaby