relax requirements for vector==

veksler@il.ibm.com veksler@il.ibm.com
Tue Mar 6 02:58:00 GMT 2001


The problem:

When value type of vector has operator== and has not operator!= (it is not
strictly EqualityComparable), vector::operator== will not compile. Although
this may be correct according to the standard (?), it is a dumb behavior
and should be fixed.

I grepped all of the includes, to make sure there are no more similar
instances:
   find libstdc++-v3/include -type f | xargs grep '\!= *\*'

This matched only 2 cases:
1. locale_facets.tcc (_CharT::operator!=)
2. stl_algobase.h (our case)


The patch:

Index: libstdc++-v3/include/bits/stl_algobase.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_algobase.h,v
retrieving revision 1.3
diff -u -r1.3 stl_algobase.h
--- stl_algobase.h      2001/01/25 15:35:10     1.3
+++ stl_algobase.h      2001/03/06 10:28:42
@@ -599,7 +599,7 @@
   __STL_REQUIRES(typename iterator_traits<_InputIter2>::value_type,
                  _EqualityComparable);
   for ( ; __first1 != __last1; ++__first1, ++__first2)
-    if (*__first1 != *__first2)
+    if (!(*__first1 == *__first2))
       return false;
   return true;
 }




More information about the Libstdc++ mailing list