From 119ed479997f73f39aa0dc4ea5b5ca5ae36300fb Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 14 Jul 2015 14:46:32 +0000 Subject: [PATCH] Move bits from N4258. Mark vector's move-constructor unconditionally noexcept in C++1z git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242148 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/vector | 16 ++++++++++++++++ .../sequences/vector.bool/move_noexcept.pass.cpp | 5 +++++ .../vector/vector.cons/move_noexcept.pass.cpp | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/include/vector b/include/vector index 65a087cf8..c168c8ea6 100644 --- a/include/vector +++ b/include/vector @@ -553,7 +553,11 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __x) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_constructible::value); +#endif _LIBCPP_INLINE_VISIBILITY vector(vector&& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY @@ -1220,7 +1224,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_constructible::value) +#endif : __base(_VSTD::move(__x.__alloc())) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -2195,7 +2203,11 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY vector(vector&& __v) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_constructible::value); +#endif vector(vector&& __v, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) @@ -2785,7 +2797,11 @@ vector::operator=(const vector& __v) template inline _LIBCPP_INLINE_VISIBILITY vector::vector(vector&& __v) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_constructible::value) +#endif : __begin_(__v.__begin_), __size_(__v.__size_), __cap_alloc_(__v.__cap_alloc_) diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index ab32bd067..132186b55 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -43,7 +43,12 @@ int main() } { typedef std::vector> C; + // In C++17, move constructors for allocators are not allowed to throw +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_constructible::value, ""); +#else static_assert(!std::is_nothrow_move_constructible::value, ""); +#endif } #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp index 46cad9925..b7bbfaa42 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp @@ -44,7 +44,12 @@ int main() } { typedef std::vector> C; + // In C++17, move constructors for allocators are not allowed to throw +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_constructible::value, ""); +#else static_assert(!std::is_nothrow_move_constructible::value, ""); +#endif } #endif }