[libcxx] r316456 - Mark string_view's constructor from (ptr, len) as noexcept (an extension). Update the tests to check this (and other noexcept bits
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 09:30:06 PDT 2017
Author: marshall
Date: Tue Oct 24 09:30:06 2017
New Revision: 316456
URL: http://llvm.org/viewvc/llvm-project?rev=316456&view=rev
Log:
Mark string_view's constructor from (ptr,len) as noexcept (an extension). Update the tests to check this (and other noexcept bits
Modified:
libcxx/trunk/include/string_view
libcxx/trunk/test/std/strings/string.view/string.view.cons/default.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp
libcxx/trunk/test/std/strings/string.view/string.view.cons/from_string.pass.cpp
Modified: libcxx/trunk/include/string_view
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string_view?rev=316456&r1=316455&r2=316456&view=diff
==============================================================================
--- libcxx/trunk/include/string_view (original)
+++ libcxx/trunk/include/string_view Tue Oct 24 09:30:06 2017
@@ -216,7 +216,7 @@ public:
basic_string_view& operator=(const basic_string_view&) _NOEXCEPT = default;
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
- basic_string_view(const _CharT* __s, size_type __len)
+ basic_string_view(const _CharT* __s, size_type __len) _NOEXCEPT
: __data(__s), __size(__len)
{
// #if _LIBCPP_STD_VER > 11
Modified: libcxx/trunk/test/std/strings/string.view/string.view.cons/default.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/default.pass.cpp?rev=316456&r1=316455&r2=316456&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.cons/default.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.cons/default.pass.cpp Tue Oct 24 09:30:06 2017
@@ -21,6 +21,8 @@ template<typename T>
void test () {
#if TEST_STD_VER > 11
{
+ ASSERT_NOEXCEPT(T());
+
constexpr T sv1;
static_assert ( sv1.size() == 0, "" );
static_assert ( sv1.empty(), "");
Modified: libcxx/trunk/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp?rev=316456&r1=316455&r2=316456&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp Tue Oct 24 09:30:06 2017
@@ -30,7 +30,11 @@ size_t StrLen ( const CharT *s ) {
template<typename CharT>
void test ( const CharT *s ) {
- std::basic_string_view<CharT> sv1 ( s );
+ typedef std::basic_string_view<CharT> SV;
+// I'd love to do this, but it would require traits::length() to be noexcept
+// LIBCPP_ASSERT_NOEXCEPT(SV(s));
+
+ SV sv1 ( s );
assert ( sv1.size() == StrLen( s ));
assert ( sv1.data() == s );
}
Modified: libcxx/trunk/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp?rev=316456&r1=316455&r2=316456&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp Tue Oct 24 09:30:06 2017
@@ -23,7 +23,10 @@
template<typename CharT>
void test ( const CharT *s, size_t sz ) {
{
- std::basic_string_view<CharT> sv1 ( s, sz );
+ typedef std::basic_string_view<CharT> SV;
+ LIBCPP_ASSERT_NOEXCEPT(SV(s, sz));
+
+ SV sv1 ( s, sz );
assert ( sv1.size() == sz );
assert ( sv1.data() == s );
}
Modified: libcxx/trunk/test/std/strings/string.view/string.view.cons/from_string.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/strings/string.view/string.view.cons/from_string.pass.cpp?rev=316456&r1=316455&r2=316456&view=diff
==============================================================================
--- libcxx/trunk/test/std/strings/string.view/string.view.cons/from_string.pass.cpp (original)
+++ libcxx/trunk/test/std/strings/string.view/string.view.cons/from_string.pass.cpp Tue Oct 24 09:30:06 2017
@@ -24,7 +24,10 @@ struct dummy_char_traits : public std::c
template<typename CharT, typename Traits>
void test ( const std::basic_string<CharT, Traits> &str ) {
- std::basic_string_view<CharT, Traits> sv1 ( str );
+ typedef std::basic_string_view<CharT, Traits> SV;
+ ASSERT_NOEXCEPT(SV(str));
+
+ SV sv1 ( str );
assert ( sv1.size() == str.size());
assert ( sv1.data() == str.data());
}
More information about the cfe-commits
mailing list