[libcxx] r316439 - Mark string_view literals as 'noexcept'. Fixes PR#25054. Thanks to Pavel K for the bug report.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 07:06:00 PDT 2017
Author: marshall
Date: Tue Oct 24 07:06:00 2017
New Revision: 316439
URL: http://llvm.org/viewvc/llvm-project?rev=316439&view=rev
Log:
Mark string_view literals as 'noexcept'. Fixes PR#25054. Thanks to Pavel K for the bug report.
Modified:
libcxx/trunk/include/string_view
libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp
Modified: libcxx/trunk/include/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string_view?rev=316439&r1=316438&r2=316439&view=diff
==============================================================================
--- libcxx/trunk/include/string_view (original)
+++ libcxx/trunk/include/string_view Tue Oct 24 07:06:00 2017
@@ -155,10 +155,10 @@ namespace std {
template <> struct hash<u32string_view>;
template <> struct hash<wstring_view>;
- constexpr basic_string<char> operator "" s( const char *str, size_t len ); // C++17
- constexpr basic_string<wchar_t> operator "" s( const wchar_t *str, size_t len ); // C++17
- constexpr basic_string<char16_t> operator "" s( const char16_t *str, size_t len ); // C++17
- constexpr basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++17
+ constexpr basic_string_view<char> operator "" sv( const char *str, size_t len ) noexcept;
+ constexpr basic_string_view<wchar_t> operator "" sv( const wchar_t *str, size_t len ) noexcept;
+ constexpr basic_string_view<char16_t> operator "" sv( const char16_t *str, size_t len ) noexcept;
+ constexpr basic_string_view<char32_t> operator "" sv( const char32_t *str, size_t len ) noexcept;
} // namespace std
@@ -760,25 +760,25 @@ inline namespace literals
inline namespace string_view_literals
{
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- basic_string_view<char> operator "" sv(const char *__str, size_t __len)
+ basic_string_view<char> operator "" sv(const char *__str, size_t __len) _NOEXCEPT
{
return basic_string_view<char> (__str, __len);
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
+ basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len) _NOEXCEPT
{
return basic_string_view<wchar_t> (__str, __len);
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
+ basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len) _NOEXCEPT
{
return basic_string_view<char16_t> (__str, __len);
}
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
- basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
+ basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len) _NOEXCEPT
{
return basic_string_view<char32_t> (__str, __len);
}
Modified: libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp?rev=316439&r1=316438&r2=316439&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string_view.literals/literal.pass.cpp Tue Oct 24 07:06:00 2017
@@ -54,4 +54,10 @@ int main()
static_assert( L"ABC"sv.size() == 3, "");
static_assert( u"ABC"sv.size() == 3, "");
static_assert( U"ABC"sv.size() == 3, "");
+
+ static_assert(noexcept( "ABC"sv), "");
+ static_assert(noexcept(u8"ABC"sv), "");
+ static_assert(noexcept( L"ABC"sv), "");
+ static_assert(noexcept( u"ABC"sv), "");
+ static_assert(noexcept( U"ABC"sv), "");
}
More information about the cfe-commits
mailing list