diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -3882,6 +3882,18 @@ return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } +template<> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const char* __lhs, + const string& __rhs) _NOEXCEPT +{ + _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); + size_t __lhs_len = strlen(__lhs); + if (__lhs_len != __rhs.size()) return false; + return memcmp(__rhs.data(), __lhs, __lhs_len) == 0; +} + template inline _LIBCPP_INLINE_VISIBILITY bool @@ -3895,6 +3907,17 @@ return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; } +template <> +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const string& __lhs, + const char* __rhs) _NOEXCEPT { + _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); + const size_t __rhs_len = strlen(__rhs); + if (__rhs_len != __lhs.size()) return false; + return memcmp(__lhs.data(), __rhs, __rhs_len) == 0; +} + template inline _LIBCPP_INLINE_VISIBILITY bool