[PATCH] PR libstdc++/82685 add 'noexcept' to string_view literals

Jonathan Wakely jwakely@redhat.com
Tue Oct 24 12:09:00 GMT 2017


C++17 says these operators should be noexcept (and Clang-Tidy can't
figure out they don't throw otherwise). LFTS doesn't have these
literals, but we'd be able to make them noexcept anyway, just because
we like to do that.

	PR libstdc++/82685
	* include/experimental/string_view (operator""sv): Add noexcept.
	* include/std/string_view (operator""sv): Likewise.

Tested powerpc64le-linux, committed to trunk. I'll backport it too.


-------------- next part --------------
commit 070f50e622e028716c3eeb2e1b520093bb4eb4f2
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Oct 24 01:53:52 2017 +0100

    PR libstdc++/82685 add 'noexcept' to string_view literals
    
            PR libstdc++/82685
            * include/experimental/string_view (operator""sv): Add noexcept.
            * include/std/string_view (operator""sv): Likewise.

diff --git a/libstdc++-v3/include/experimental/string_view b/libstdc++-v3/include/experimental/string_view
index f05f152302a..8eaf9ec3d96 100644
--- a/libstdc++-v3/include/experimental/string_view
+++ b/libstdc++-v3/include/experimental/string_view
@@ -645,22 +645,22 @@ namespace experimental
   inline namespace string_view_literals
   {
     inline constexpr basic_string_view<char>
-    operator""sv(const char* __str, size_t __len)
+    operator""sv(const char* __str, size_t __len) noexcept
     { return basic_string_view<char>{__str, __len}; }
 
 #ifdef _GLIBCXX_USE_WCHAR_T
     inline constexpr basic_string_view<wchar_t>
-    operator""sv(const wchar_t* __str, size_t __len)
+    operator""sv(const wchar_t* __str, size_t __len) noexcept
     { return basic_string_view<wchar_t>{__str, __len}; }
 #endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
     inline constexpr basic_string_view<char16_t>
-    operator""sv(const char16_t* __str, size_t __len)
+    operator""sv(const char16_t* __str, size_t __len) noexcept
     { return basic_string_view<char16_t>{__str, __len}; }
 
     inline constexpr basic_string_view<char32_t>
-    operator""sv(const char32_t* __str, size_t __len)
+    operator""sv(const char32_t* __str, size_t __len) noexcept
     { return basic_string_view<char32_t>{__str, __len}; }
 #endif
   } // namespace string_literals
diff --git a/libstdc++-v3/include/std/string_view b/libstdc++-v3/include/std/string_view
index 97316ef49ab..110a235a4c0 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -636,22 +636,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   inline namespace string_view_literals
   {
     inline constexpr basic_string_view<char>
-    operator""sv(const char* __str, size_t __len)
+    operator""sv(const char* __str, size_t __len) noexcept
     { return basic_string_view<char>{__str, __len}; }
 
 #ifdef _GLIBCXX_USE_WCHAR_T
     inline constexpr basic_string_view<wchar_t>
-    operator""sv(const wchar_t* __str, size_t __len)
+    operator""sv(const wchar_t* __str, size_t __len) noexcept
     { return basic_string_view<wchar_t>{__str, __len}; }
 #endif
 
 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
     inline constexpr basic_string_view<char16_t>
-    operator""sv(const char16_t* __str, size_t __len)
+    operator""sv(const char16_t* __str, size_t __len) noexcept
     { return basic_string_view<char16_t>{__str, __len}; }
 
     inline constexpr basic_string_view<char32_t>
-    operator""sv(const char32_t* __str, size_t __len)
+    operator""sv(const char32_t* __str, size_t __len) noexcept
     { return basic_string_view<char32_t>{__str, __len}; }
 #endif
   } // namespace string_literals


More information about the Gcc-patches mailing list