diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b5d9ce33b89..b0ab719c065 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,8 +1,22 @@ +2007-07-27 Paolo Carlini + + PR libstdc++/32907 + * include/bits/basic_string.h (operator==(const basic_string<_CharT>&, + const basic_string<_CharT>&)): Add. + (operator!=): Forward to operator==. + * include/ext/vstring.h(operator==(const __versa_string<_CharT, + std::char_traits<_CharT>, std::allocator<_CharT>, _Base>&, + const __versa_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT>, _Base>&)): Add. + (operator!=): Forward to operator==. + + * include/ext/sso_string_base.h (_M_compare): Remove. + 2007-07-25 Stephen M. Webb - Fixed abi_check for missing symbol size changes. - * testsuite/util/testsuite_abi.cc: Changed local variable name to prevent - member variable hiding. + Fixed abi_check for missing symbol size changes. + * testsuite/util/testsuite_abi.cc: Changed local variable name to + prevent member variable hiding. 2007-07-25 John Davind Anglin @@ -26,8 +40,10 @@ * testsuite/thread/pthread5.cc: Likewise. * testsuite/thread/pthread6.cc: Likewise. * testsuite/thread/pthread7-rope.cc: Likewise. - * testsuite/tr1/2_general_utilities/shared_ptr/thread/default_weaktoshared.cc: Likewise. - * testsuite/tr1/2_general_utilities/shared_ptr/thread/mutex_weaktoshared.cc: Likewise. + * testsuite/tr1/2_general_utilities/shared_ptr/thread/ + default_weaktoshared.cc: Likewise. + * testsuite/tr1/2_general_utilities/shared_ptr/thread/ + mutex_weaktoshared.cc: Likewise. 2007-07-16 Danny Smith diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 6317b17cab3..2dc3b37253e 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -2157,6 +2157,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) const basic_string<_CharT, _Traits, _Alloc>& __rhs) { return __lhs.compare(__rhs) == 0; } + template + inline + typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value, bool>::__type + operator==(const basic_string<_CharT>& __lhs, + const basic_string<_CharT>& __rhs) + { return (__lhs.size() == __rhs.size() + && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), + __lhs.size())); } + /** * @brief Test equivalence of C string and string. * @param lhs C string. @@ -2192,7 +2201,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) - { return __rhs.compare(__lhs) != 0; } + { return !(__lhs == __rhs); } /** * @brief Test difference of C string and string. @@ -2204,7 +2213,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Alloc>& __rhs) - { return __rhs.compare(__lhs) != 0; } + { return !(__lhs == __rhs); } /** * @brief Test difference of string and C string. @@ -2216,7 +2225,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) inline bool operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, const _CharT* __rhs) - { return __lhs.compare(__rhs) != 0; } + { return !(__lhs == __rhs); } // operator < /** diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h index 3b87879c4ca..0b576ba35b1 100644 --- a/libstdc++-v3/include/ext/sso_string_base.h +++ b/libstdc++-v3/include/ext/sso_string_base.h @@ -540,30 +540,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) _M_set_length(_M_length() - __n); } - template<> - inline bool - __sso_string_base, - std::allocator >:: - _M_compare(const __sso_string_base& __rcs) const - { - if (this == &__rcs) - return true; - return false; - } - -#ifdef _GLIBCXX_USE_WCHAR_T - template<> - inline bool - __sso_string_base, - std::allocator >:: - _M_compare(const __sso_string_base& __rcs) const - { - if (this == &__rcs) - return true; - return false; - } -#endif - _GLIBCXX_END_NAMESPACE #endif /* _SSO_STRING_BASE_H */ diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index b46a6bec607..bafa0449b23 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -1867,6 +1867,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) { return __lhs.compare(__rhs) == 0; } + template class _Base> + inline typename __enable_if::__value, bool>::__type + operator==(const __versa_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT>, _Base>& __lhs, + const __versa_string<_CharT, std::char_traits<_CharT>, + std::allocator<_CharT>, _Base>& __rhs) + { return (__lhs.size() == __rhs.size() + && !std::char_traits<_CharT>::compare(__lhs.data(), __rhs.data(), + __lhs.size())); } + /** * @brief Test equivalence of C string and string. * @param lhs C string. @@ -1905,7 +1916,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) inline bool operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) - { return __rhs.compare(__lhs) != 0; } + { return !(__lhs == __rhs); } /** * @brief Test difference of C string and string. @@ -1918,7 +1929,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) inline bool operator!=(const _CharT* __lhs, const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs) - { return __rhs.compare(__lhs) != 0; } + { return !(__lhs == __rhs); } /** * @brief Test difference of string and C string. @@ -1931,7 +1942,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) inline bool operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs, const _CharT* __rhs) - { return __lhs.compare(__rhs) != 0; } + { return !(__lhs == __rhs); } // operator < /**