This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA] Removing const from std::swap


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]