diff options
author | dim <dim@FreeBSD.org> | 2012-10-22 18:25:04 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2012-10-22 18:25:04 +0000 |
commit | 708d8e446e991358da23bb52ec5320440221f12f (patch) | |
tree | 3a061d75674cd5b60d9f6df45d0b8d755da3782f /contrib/libc++/include/string | |
parent | b8c74d455d2690e710a0802a98a9d310995a52eb (diff) | |
parent | 13334223d751d249ccd6475b8cba36ff71ddc972 (diff) | |
download | FreeBSD-src-708d8e446e991358da23bb52ec5320440221f12f.zip FreeBSD-src-708d8e446e991358da23bb52ec5320440221f12f.tar.gz |
Import libc++ trunk r165949. Among other improvements and bug fixes,
this has many visibility problems fixed, which should help with
compiling certain ports that exercise C++11 mode (i.e. Firefox).
Also, belatedly add the LICENSE.TXT and accompanying CREDITS.TXT files,
which are referred to in all the source files.
MFC after: 1 month
Diffstat (limited to 'contrib/libc++/include/string')
-rw-r--r-- | contrib/libc++/include/string | 87 |
1 files changed, 45 insertions, 42 deletions
diff --git a/contrib/libc++/include/string b/contrib/libc++/include/string index 620e6f8..89a00e5 100644 --- a/contrib/libc++/include/string +++ b/contrib/libc++/include/string @@ -51,8 +51,8 @@ struct char_traits typedef mbstate_t state_type; static void assign(char_type& c1, const char_type& c2) noexcept; - static bool eq(char_type c1, char_type c2) noexcept; - static bool lt(char_type c1, char_type c2) noexcept; + static constexpr bool eq(char_type c1, char_type c2) noexcept; + static constexpr bool lt(char_type c1, char_type c2) noexcept; static int compare(const char_type* s1, const char_type* s2, size_t n); static size_t length(const char_type* s); @@ -61,11 +61,11 @@ struct char_traits static char_type* copy(char_type* s1, const char_type* s2, size_t n); static char_type* assign(char_type* s, size_t n, char_type a); - static int_type not_eof(int_type c) noexcept; - static char_type to_char_type(int_type c) noexcept; - static int_type to_int_type(char_type c) noexcept; - static bool eq_int_type(int_type c1, int_type c2) noexcept; - static int_type eof() noexcept; + static constexpr int_type not_eof(int_type c) noexcept; + static constexpr char_type to_char_type(int_type c) noexcept; + static constexpr int_type to_int_type(char_type c) noexcept; + static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept; + static constexpr int_type eof() noexcept; }; template <> struct char_traits<char>; @@ -506,10 +506,10 @@ struct _LIBCPP_VISIBLE char_traits static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} _LIBCPP_INLINE_VISIBILITY - static bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -519,19 +519,20 @@ struct _LIBCPP_VISIBLE char_traits static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); static char_type* assign(char_type* __s, size_t __n, char_type __a); - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY + static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} _LIBCPP_INLINE_VISIBILITY - static char_type to_char_type(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} _LIBCPP_INLINE_VISIBILITY - static int_type to_int_type(char_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} _LIBCPP_INLINE_VISIBILITY - static bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static int_type eof() _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(EOF);} }; @@ -631,10 +632,10 @@ struct _LIBCPP_VISIBLE char_traits<char> static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} _LIBCPP_INLINE_VISIBILITY - static bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return (unsigned char)__c1 < (unsigned char)__c2;} _LIBCPP_INLINE_VISIBILITY @@ -655,19 +656,20 @@ struct _LIBCPP_VISIBLE char_traits<char> static char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)memset(__s, to_int_type(__a), __n);} - _LIBCPP_INLINE_VISIBILITY static int_type not_eof(int_type __c) _NOEXCEPT + _LIBCPP_INLINE_VISIBILITY + static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} _LIBCPP_INLINE_VISIBILITY - static char_type to_char_type(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} _LIBCPP_INLINE_VISIBILITY - static int_type to_int_type(char_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type((unsigned char)__c);} _LIBCPP_INLINE_VISIBILITY - static bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static int_type eof() _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(EOF);} }; @@ -686,10 +688,10 @@ struct _LIBCPP_VISIBLE char_traits<wchar_t> static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} _LIBCPP_INLINE_VISIBILITY - static bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} _LIBCPP_INLINE_VISIBILITY @@ -712,19 +714,19 @@ struct _LIBCPP_VISIBLE char_traits<wchar_t> {return (char_type*)wmemset(__s, __a, __n);} _LIBCPP_INLINE_VISIBILITY - static int_type not_eof(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} _LIBCPP_INLINE_VISIBILITY - static char_type to_char_type(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} _LIBCPP_INLINE_VISIBILITY - static int_type to_int_type(char_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} _LIBCPP_INLINE_VISIBILITY - static bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static int_type eof() _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(WEOF);} }; @@ -743,10 +745,10 @@ struct _LIBCPP_VISIBLE char_traits<char16_t> static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} _LIBCPP_INLINE_VISIBILITY - static bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -757,19 +759,19 @@ struct _LIBCPP_VISIBLE char_traits<char16_t> static char_type* assign(char_type* __s, size_t __n, char_type __a); _LIBCPP_INLINE_VISIBILITY - static int_type not_eof(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} _LIBCPP_INLINE_VISIBILITY - static char_type to_char_type(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} _LIBCPP_INLINE_VISIBILITY - static int_type to_int_type(char_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} _LIBCPP_INLINE_VISIBILITY - static bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static int_type eof() _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(0xDFFF);} }; @@ -863,10 +865,10 @@ struct _LIBCPP_VISIBLE char_traits<char32_t> static void assign(char_type& __c1, const char_type& __c2) _NOEXCEPT {__c1 = __c2;} _LIBCPP_INLINE_VISIBILITY - static bool eq(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static bool lt(char_type __c1, char_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); @@ -877,19 +879,19 @@ struct _LIBCPP_VISIBLE char_traits<char32_t> static char_type* assign(char_type* __s, size_t __n, char_type __a); _LIBCPP_INLINE_VISIBILITY - static int_type not_eof(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT {return eq_int_type(__c, eof()) ? ~eof() : __c;} _LIBCPP_INLINE_VISIBILITY - static char_type to_char_type(int_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR char_type to_char_type(int_type __c) _NOEXCEPT {return char_type(__c);} _LIBCPP_INLINE_VISIBILITY - static int_type to_int_type(char_type __c) _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type to_int_type(char_type __c) _NOEXCEPT {return int_type(__c);} _LIBCPP_INLINE_VISIBILITY - static bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT + static _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} _LIBCPP_INLINE_VISIBILITY - static int_type eof() _NOEXCEPT + static _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT {return int_type(0xFFFFFFFF);} }; @@ -2206,6 +2208,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _Input clear(); for (; __first != __last; ++__first) push_back(*__first); + return *this; } template <class _CharT, class _Traits, class _Allocator> |