https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93059

--- Comment #37 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Similarly, the condition for using memcmp in std::equal is too strict:

      typedef typename iterator_traits<_II1>::value_type _ValueType1;
      typedef typename iterator_traits<_II2>::value_type _ValueType2;
      const bool __simple = ((__is_integer<_ValueType1>::__value
                              || __is_pointer<_ValueType1>::__value)
                             && __is_pointer<_II1>::__value
                             && __is_pointer<_II2>::__value
                             && __are_same<_ValueType1, _ValueType2>::__value);

If the types are integers of the same size and same signedness then we can use
memcmp, they don't have to be exactly the same type.

And for lexicographical_compare we have:

      typedef typename iterator_traits<_II1>::value_type _ValueType1;
      typedef typename iterator_traits<_II2>::value_type _ValueType2;
      const bool __simple =
        (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value
         && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed
         && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed
         && __is_pointer<_II1>::__value
         && __is_pointer<_II2>::__value);

On big endian targets we could also use memcmp for unsigned integer types
larger than one byte.

Reply via email to