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


Gabriel Dos Reis wrote:

>I'll look at it differently: Does the const buy us anything?  If not,
>it should be removed.
>  
>
Right, already tested patch below.

>| If we keep it, auto_ptrs cannot be swapped, as an extension,
>| indeed...
>
>I do not follow here.
>  
>
Well, the thread started with a message about a failed attempt to swap
auto_ptrs, which are not Assignable, right? Or I'm misunderstanding your
doubt?

Paolo.

///////////
2005-05-19  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/stl_algo.h (__rotate<_RandomAccessIterator>):
	Don't qualify __tmp as const, _ValueType is not necessarily
	Assignable.
	* include/bits/stl_algobase.h (swap, __iter_swap<false>):
	Likewise, as an harmless extension.
diff -urN libstdc++-v3-orig/include/bits/stl_algo.h libstdc++-v3/include/bits/stl_algo.h
--- libstdc++-v3-orig/include/bits/stl_algo.h	2005-04-28 09:50:40.000000000 +0200
+++ libstdc++-v3/include/bits/stl_algo.h	2005-05-19 17:40:53.000000000 +0200
@@ -1,6 +1,6 @@
 // Algorithm implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -1637,7 +1637,7 @@
 
       for (_Distance __i = 0; __i < __d; __i++)
 	{
-	  const _ValueType __tmp = *__first;
+	  _ValueType __tmp = *__first;
 	  _RandomAccessIterator __p = __first;
 
 	  if (__k < __l)
diff -urN libstdc++-v3-orig/include/bits/stl_algobase.h libstdc++-v3/include/bits/stl_algobase.h
--- libstdc++-v3-orig/include/bits/stl_algobase.h	2005-03-21 23:16:15.000000000 +0100
+++ libstdc++-v3/include/bits/stl_algobase.h	2005-05-19 17:41:50.000000000 +0200
@@ -94,7 +94,7 @@
       // concept requirements
       __glibcxx_function_requires(_SGIAssignableConcept<_Tp>)
 
-      const _Tp __tmp = __a;
+      _Tp __tmp = __a;
       __a = __b;
       __b = __tmp;
     }
@@ -111,7 +111,7 @@
         {
           typedef typename iterator_traits<_ForwardIterator1>::value_type
             _ValueType1;
-          const _ValueType1 __tmp = *__a;
+          _ValueType1 __tmp = *__a;
           *__a = *__b;
           *__b = __tmp; 
 	}

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