diff options
Diffstat (limited to 'libstdc++-v3/include/bits/basic_string.h')
-rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 15 |
1 files changed, 12 insertions, 3 deletions
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<typename _CharT> + 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 < /** |