summaryrefslogtreecommitdiffstats
path: root/contrib/libc++/include/string
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2013-04-27 22:47:52 +0000
committerdim <dim@FreeBSD.org>2013-04-27 22:47:52 +0000
commit815a6cc1e325a4e8596b91756039a7d699471b11 (patch)
treee5a6a26d0973c6968273f6fabb61cb3d624be555 /contrib/libc++/include/string
parent1497a98f71419ff66d08ad2b8c90530e65521ac2 (diff)
downloadFreeBSD-src-815a6cc1e325a4e8596b91756039a7d699471b11.zip
FreeBSD-src-815a6cc1e325a4e8596b91756039a7d699471b11.tar.gz
Merge libc++ trunk r180598. Contains several minor cleanups and bug
fixes, no major changes. MFC after: 2 weeks
Diffstat (limited to 'contrib/libc++/include/string')
-rw-r--r--contrib/libc++/include/string51
1 files changed, 36 insertions, 15 deletions
diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string
index 1a70467..fa44f68 100644
--- a/contrib/libc++/include/string
+++ b/contrib/libc++/include/string
@@ -457,7 +457,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// fpos
template <class _StateT>
-class _LIBCPP_VISIBLE fpos
+class _LIBCPP_TYPE_VIS fpos
{
private:
_StateT __st_;
@@ -494,7 +494,7 @@ bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y)
// char_traits
template <class _CharT>
-struct _LIBCPP_VISIBLE char_traits
+struct _LIBCPP_TYPE_VIS char_traits
{
typedef _CharT char_type;
typedef int int_type;
@@ -620,7 +620,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a)
// char_traits<char>
template <>
-struct _LIBCPP_VISIBLE char_traits<char>
+struct _LIBCPP_TYPE_VIS char_traits<char>
{
typedef char char_type;
typedef int int_type;
@@ -676,7 +676,7 @@ struct _LIBCPP_VISIBLE char_traits<char>
// char_traits<wchar_t>
template <>
-struct _LIBCPP_VISIBLE char_traits<wchar_t>
+struct _LIBCPP_TYPE_VIS char_traits<wchar_t>
{
typedef wchar_t char_type;
typedef wint_t int_type;
@@ -733,7 +733,7 @@ struct _LIBCPP_VISIBLE char_traits<wchar_t>
#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS
template <>
-struct _LIBCPP_VISIBLE char_traits<char16_t>
+struct _LIBCPP_TYPE_VIS char_traits<char16_t>
{
typedef char16_t char_type;
typedef uint_least16_t int_type;
@@ -853,7 +853,7 @@ char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a)
}
template <>
-struct _LIBCPP_VISIBLE char_traits<char32_t>
+struct _LIBCPP_TYPE_VIS char_traits<char32_t>
{
typedef char32_t char_type;
typedef uint_least32_t int_type;
@@ -1037,7 +1037,7 @@ _LIBCPP_EXTERN_TEMPLATE(class __basic_string_common<true>)
#endif // _MSC_VER
template<class _CharT, class _Traits, class _Allocator>
-class _LIBCPP_VISIBLE basic_string
+class _LIBCPP_TYPE_VIS basic_string
: private __basic_string_common<true>
{
public:
@@ -1462,6 +1462,11 @@ public:
int compare(size_type __pos1, size_type __n1, const_pointer __s, size_type __n2) const;
_LIBCPP_INLINE_VISIBILITY bool __invariants() const;
+
+ _LIBCPP_INLINE_VISIBILITY
+ bool __is_long() const _NOEXCEPT
+ {return bool(__r_.first().__s.__size_ & __short_mask);}
+
private:
_LIBCPP_INLINE_VISIBILITY
allocator_type& __alloc() _NOEXCEPT
@@ -1471,10 +1476,6 @@ private:
{return __r_.second();}
_LIBCPP_INLINE_VISIBILITY
- bool __is_long() const _NOEXCEPT
- {return bool(__r_.first().__s.__size_ & __short_mask);}
-
- _LIBCPP_INLINE_VISIBILITY
void __set_short_size(size_type __s) _NOEXCEPT
#if _LIBCPP_BIG_ENDIAN
{__r_.first().__s.__size_ = (unsigned char)(__s);}
@@ -3561,9 +3562,29 @@ bool
operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs,
const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT
{
- return __lhs.size() == __rhs.size() && _Traits::compare(__lhs.data(),
- __rhs.data(),
- __lhs.size()) == 0;
+ size_t __lhs_sz = __lhs.size();
+ return __lhs_sz == __rhs.size() && _Traits::compare(__lhs.data(),
+ __rhs.data(),
+ __lhs_sz) == 0;
+}
+
+template<class _Allocator>
+_LIBCPP_INLINE_VISIBILITY inline
+bool
+operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs,
+ const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT
+{
+ size_t __lhs_sz = __lhs.size();
+ if (__lhs_sz != __rhs.size())
+ return false;
+ const char* __lp = __lhs.data();
+ const char* __rp = __rhs.data();
+ if (__lhs.__is_long())
+ return char_traits<char>::compare(__lp, __rp, __lhs_sz) == 0;
+ for (; __lhs_sz != 0; --__lhs_sz, ++__lp, ++__rp)
+ if (*__lp != *__rp)
+ return false;
+ return true;
}
template<class _CharT, class _Traits, class _Allocator>
@@ -3923,7 +3944,7 @@ size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e)
}
template<class _CharT, class _Traits, class _Allocator>
-struct _LIBCPP_VISIBLE hash<basic_string<_CharT, _Traits, _Allocator> >
+struct _LIBCPP_TYPE_VIS hash<basic_string<_CharT, _Traits, _Allocator> >
: public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t>
{
size_t
OpenPOWER on IntegriCloud