Index: include/string =================================================================== --- include/string +++ include/string @@ -1123,6 +1123,27 @@ return __murmur2_or_cityhash()(__p, (__e-__p)*sizeof(value_type)); } + +template +inline _LIBCPP_INLINE_VISIBILITY +int __do_string_compare(_LHS const& __lhs, _RHS const& __rhs) { + return __lhs.compare(0, _LHS::npos, __rhs, _LHS::traits_type::length(__rhs)); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +int __do_string_compare(const basic_string, _Allocator>& __lhs, + const char* __rhs) { + return _VSTD::strcmp(__lhs.data(), __rhs); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +int __do_string_compare(const basic_string, _Allocator>& __lhs, + const wchar_t* __rhs) { + return _VSTD::wcscmp(__lhs.data(), __rhs); +} + // basic_string template @@ -3702,7 +3723,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { _LIBCPP_ASSERT(__s != nullptr, "string::compare(): received nullptr"); - return compare(0, npos, __s, traits_type::length(__s)); + return __do_string_compare(*this, __s); } template