Move the test for zero-length into the char_traits (from string_view). Add tests to char_traits specializations
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@228981 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -375,7 +375,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
|
||||
_LIBCPP_CONSTEXPR_AFTER_CXX11 int compare(basic_string_view __sv) const _NOEXCEPT
|
||||
{
|
||||
size_type __rlen = _VSTD::min( size(), __sv.size());
|
||||
int __retval = __rlen == 0 ? 0 : _Traits::compare(data(), __sv.data(), __rlen);
|
||||
int __retval = _Traits::compare(data(), __sv.data(), __rlen);
|
||||
if ( __retval == 0 ) // first __rlen chars matched
|
||||
__retval = size() == __sv.size() ? 0 : ( size() < __sv.size() ? -1 : 1 );
|
||||
return __retval;
|
||||
|
@@ -636,7 +636,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
|
||||
{return (unsigned char)__c1 < (unsigned char)__c2;}
|
||||
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return memcmp(__s1, __s2, __n);}
|
||||
{return __n == 0 ? 0 : memcmp(__s1, __s2, __n);}
|
||||
static inline size_t length(const char_type* __s) {return strlen(__s);}
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
{return (const char_type*)memchr(__s, to_int_type(__a), __n);}
|
||||
@@ -681,7 +681,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
|
||||
{return __c1 < __c2;}
|
||||
|
||||
static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
|
||||
{return wmemcmp(__s1, __s2, __n);}
|
||||
{return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);}
|
||||
static inline size_t length(const char_type* __s)
|
||||
{return wcslen(__s);}
|
||||
static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
|
||||
|
Reference in New Issue
Block a user