diff --git a/include/vector b/include/vector index 48e970a2..ec413fa6 100644 --- a/include/vector +++ b/include/vector @@ -501,13 +501,22 @@ public: _LIBCPP_INLINE_VISIBILITY vector() +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_default_constructible::value) +#else + _NOEXCEPT +#endif { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif : __base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -2162,8 +2171,18 @@ private: public: _LIBCPP_INLINE_VISIBILITY vector() +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_default_constructible::value); - _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); +#else + _NOEXCEPT; +#endif + + _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value); +#else + _NOEXCEPT; +#endif ~vector(); explicit vector(size_type __n); #if _LIBCPP_STD_VER > 11 @@ -2550,7 +2569,11 @@ vector::__construct_at_end(_ForwardIterator __first, _ForwardI template inline _LIBCPP_INLINE_VISIBILITY vector::vector() +#if _LIBCPP_STD_VER <= 14 _NOEXCEPT_(is_nothrow_default_constructible::value) +#else + _NOEXCEPT +#endif : __begin_(nullptr), __size_(0), __cap_alloc_(0) @@ -2560,6 +2583,11 @@ vector::vector() template inline _LIBCPP_INLINE_VISIBILITY vector::vector(const allocator_type& __a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif : __begin_(nullptr), __size_(0), __cap_alloc_(0, static_cast<__storage_allocator>(__a)) diff --git a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp index d3d6670b..07824098 100644 --- a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -22,11 +23,16 @@ template void test0() { +#if TEST_STD_VER > 14 + static_assert((noexcept(C{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" ); +#endif C c; assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 C c1 = {}; assert(c1.__invariants()); assert(c1.empty()); @@ -38,6 +44,11 @@ template void test1(const typename C::allocator_type& a) { +#if TEST_STD_VER > 14 + static_assert((noexcept(C{typename C::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible::value), "" ); +#endif C c(a); assert(c.__invariants()); assert(c.empty()); @@ -50,7 +61,7 @@ int main() test0 >(); test1 > >(test_allocator(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { test0> >(); test1 > >(min_allocator()); diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp index b94588ea..d0a96480 100644 --- a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp @@ -39,11 +39,21 @@ int main() } { typedef std::vector> C; +// See N4258 - vector::basic_string() noexcept; +#if TEST_STD_VER <= 14 static_assert(!std::is_nothrow_default_constructible::value, ""); +#else + static_assert( std::is_nothrow_default_constructible::value, ""); +#endif } { typedef std::vector> C; +// See N4258 - vector::basic_string() noexcept; +#if TEST_STD_VER <= 14 static_assert(!std::is_nothrow_default_constructible::value, ""); +#else + static_assert( std::is_nothrow_default_constructible::value, ""); +#endif } #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp index 75772bef..9d757bf5 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp @@ -9,7 +9,8 @@ // -// vector(const Alloc& = Alloc()); +// vector(); +// vector(const Alloc&); #include #include @@ -24,12 +25,17 @@ template void test0() { +#if TEST_STD_VER > 14 + static_assert((noexcept(C{})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" ); +#endif C c; assert(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); assert(is_contiguous_container_asan_correct(c)); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 C c1 = {}; assert(c1.__invariants()); assert(c1.empty()); @@ -42,6 +48,11 @@ template void test1(const typename C::allocator_type& a) { +#if TEST_STD_VER > 14 + static_assert((noexcept(C{typename C::allocator_type{}})), "" ); +#elif TEST_STD_VER >= 11 + static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible::value), "" ); +#endif C c(a); assert(c.__invariants()); assert(c.empty()); @@ -62,7 +73,7 @@ int main() std::vector > v; assert(v.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { test0> >(); test0> >(); diff --git a/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp index 471c1d40..e13a5fc0 100644 --- a/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -40,11 +41,21 @@ int main() } { typedef std::vector> C; +// See N4258 - vector::basic_string() noexcept; +#if TEST_STD_VER <= 14 static_assert(!std::is_nothrow_default_constructible::value, ""); +#else + static_assert( std::is_nothrow_default_constructible::value, ""); +#endif } { typedef std::vector> C; +// See N4258 - vector::basic_string() noexcept; +#if TEST_STD_VER <= 14 static_assert(!std::is_nothrow_default_constructible::value, ""); +#else + static_assert( std::is_nothrow_default_constructible::value, ""); +#endif } #endif }