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: [RFC/Patch] libstdc++/23767


Paolo Carlini wrote:

>What do you think? 1), 2) or... 3) ??
>  
>
The below would be a 3)

I like it a lot more: uses __enable_if but avoids introducing additional
dummy arguments and bringing in complicate is_convertible logic; avoids
code duplication; works also for _Container::pointer more general than
real pointer (as will happen in prospect if we generalize our allocators
as per the recent discussion, libstdc++/21771). Well, the only problem
is that I'm not really proud of it because I took the idea from the
debug-mode _Safe_iterator, but I learned a lot for the future!

Regtesting going, already past 26_numerics...

Paolo.

///////////////////
Index: stl_iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_iterator.h,v
retrieving revision 1.28
diff -u -r1.28 stl_iterator.h
--- stl_iterator.h	17 Aug 2005 02:13:00 -0000	1.28
+++ stl_iterator.h	11 Sep 2005 19:08:19 -0000
@@ -65,6 +65,8 @@
 #ifndef _ITERATOR_H
 #define _ITERATOR_H 1
 
+#include <bits/cpp_type_traits.h>
+
 namespace std
 {
   // 24.4.1 Reverse iterators
@@ -602,11 +604,17 @@
       explicit
       __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
 
+      __normal_iterator(const __normal_iterator& __i)
+      : _M_current(__i.base()) { }
+
       // Allow iterator to const_iterator conversion
       template<typename _Iter>
-        inline __normal_iterator(const __normal_iterator<_Iter,
-				 _Container>& __i)
-	: _M_current(__i.base()) { }
+        __normal_iterator(const __normal_iterator<_Iter,
+			  typename std::__enable_if<_Container,
+			  (std::__are_same<_Iter,
+			   typename _Container::pointer>::__value)
+			  >::__type>& __i)
+        : _M_current(__i.base()) { }
 
       // Forward iterator requirements
       reference

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