Add a bunch of noexcepts to char_traits and string_view.
authorMarshall Clow <mclow.lists@gmail.com>
Thu, 28 Jul 2016 04:52:02 +0000 (04:52 +0000)
committerMarshall Clow <mclow.lists@gmail.com>
Thu, 28 Jul 2016 04:52:02 +0000 (04:52 +0000)
llvm-svn: 276955

libcxx/include/__string
libcxx/include/string_view

index 3345411..764ee56 100644 (file)
@@ -207,19 +207,19 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char>
     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 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t>
     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 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
         {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 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t>
 
 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 @@ char_traits<char16_t>::compare(const char_type* __s1, const char_type* __s2, siz
 
 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 @@ char_traits<char16_t>::length(const char_type* __s)
 
 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 @@ char_traits<char16_t>::find(const char_type* __s, size_t __n, const char_type& _
 
 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 @@ char_traits<char16_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
 
 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 @@ char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 
 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 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
         {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 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t>
 
 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 @@ char_traits<char32_t>::compare(const char_type* __s1, const char_type* __s2, siz
 
 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 @@ char_traits<char32_t>::length(const char_type* __s)
 
 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 @@ char_traits<char32_t>::find(const char_type* __s, size_t __n, const char_type& _
 
 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 @@ char_traits<char32_t>::move(char_type* __s1, const char_type* __s2, size_t __n)
 
 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 @@ char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n)
 
 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)
index 08fcfd6..67fc606 100644 (file)
@@ -356,7 +356,7 @@ public:
        }
 
        _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY
-       int compare(const _CharT* __s) const
+       int compare(const _CharT* __s) const _NOEXCEPT
        {
                return compare(basic_string_view(__s));
        }