Add a bunch of noexcepts to char_traits and string_view.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@276955 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__string b/include/__string
index 3345411..764ee56 100644
--- a/include/__string
+++ b/include/__string
@@ -207,19 +207,19 @@
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return (unsigned char)__c1 < (unsigned char)__c2;}
- static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
+ static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{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)
+ static inline size_t length(const char_type* __s) _NOEXCEPT {return strlen(__s);}
+ static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{return __n == 0 ? NULL : (const char_type*) memchr(__s, to_int_type(__a), __n);}
- static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
+ static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*) memmove(__s1, __s2, __n);}
- static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
+ static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)memcpy(__s1, __s2, __n);
}
- static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+ static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)memset(__s, to_int_type(__a), __n);}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
@@ -252,20 +252,20 @@
static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT
{return __c1 < __c2;}
- static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n)
+ static inline int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? 0 : wmemcmp(__s1, __s2, __n);}
- static inline size_t length(const char_type* __s)
+ static inline size_t length(const char_type* __s) _NOEXCEPT
{return wcslen(__s);}
- static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a)
+ static inline const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{return __n == 0 ? NULL : (const char_type*)wmemchr(__s, __a, __n);}
- static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n)
+ static inline char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{return __n == 0 ? __s1 : (char_type*)wmemmove(__s1, __s2, __n);}
- static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n)
+ static inline char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
return __n == 0 ? __s1 : (char_type*)wmemcpy(__s1, __s2, __n);
}
- static inline char_type* assign(char_type* __s, size_t __n, char_type __a)
+ static inline char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{return __n == 0 ? __s : (char_type*)wmemset(__s, __a, __n);}
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
@@ -299,17 +299,17 @@
{return __c1 < __c2;}
_LIBCPP_INLINE_VISIBILITY
- static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
+ static int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static size_t length(const char_type* __s);
+ static size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+ static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* assign(char_type* __s, size_t __n, char_type __a);
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -325,7 +325,7 @@
inline
int
-char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
for (; __n; --__n, ++__s1, ++__s2)
{
@@ -339,7 +339,7 @@
inline
size_t
-char_traits<char16_t>::length(const char_type* __s)
+char_traits<char16_t>::length(const char_type* __s) _NOEXCEPT
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
@@ -349,7 +349,7 @@
inline
const char16_t*
-char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a)
+char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
for (; __n; --__n)
{
@@ -362,7 +362,7 @@
inline
char16_t*
-char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
char_type* __r = __s1;
if (__s1 < __s2)
@@ -382,7 +382,7 @@
inline
char16_t*
-char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
char_type* __r = __s1;
@@ -393,7 +393,7 @@
inline
char16_t*
-char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a)
+char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
char_type* __r = __s;
for (; __n; --__n, ++__s)
@@ -418,17 +418,17 @@
{return __c1 < __c2;}
_LIBCPP_INLINE_VISIBILITY
- static int compare(const char_type* __s1, const char_type* __s2, size_t __n);
+ static int compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static size_t length(const char_type* __s);
+ static size_t length(const char_type* __s) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static const char_type* find(const char_type* __s, size_t __n, const char_type& __a);
+ static const char_type* find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* move(char_type* __s1, const char_type* __s2, size_t __n);
+ static char_type* move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n);
+ static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- static char_type* assign(char_type* __s, size_t __n, char_type __a);
+ static char_type* assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT;
static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT
{return eq_int_type(__c, eof()) ? ~eof() : __c;}
@@ -444,7 +444,7 @@
inline
int
-char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
for (; __n; --__n, ++__s1, ++__s2)
{
@@ -458,7 +458,7 @@
inline
size_t
-char_traits<char32_t>::length(const char_type* __s)
+char_traits<char32_t>::length(const char_type* __s) _NOEXCEPT
{
size_t __len = 0;
for (; !eq(*__s, char_type(0)); ++__s)
@@ -468,7 +468,7 @@
inline
const char32_t*
-char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a)
+char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& __a) _NOEXCEPT
{
for (; __n; --__n)
{
@@ -481,7 +481,7 @@
inline
char32_t*
-char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
char_type* __r = __s1;
if (__s1 < __s2)
@@ -501,7 +501,7 @@
inline
char32_t*
-char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
+char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) _NOEXCEPT
{
_LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
char_type* __r = __s1;
@@ -512,7 +512,7 @@
inline
char32_t*
-char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a)
+char_traits<char32_t>::assign(char_type* __s, size_t __n, char_type __a) _NOEXCEPT
{
char_type* __r = __s;
for (; __n; --__n, ++__s)