[libcxx-commits] [libcxx] 06cf0ce - [libc++] Enable move semantics for vector in C++03

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Thu May 19 07:12:34 PDT 2022


Author: Nikolas Klauser
Date: 2022-05-19T16:11:56+02:00
New Revision: 06cf0ce90a8f5862e9a7560a422ddea171ac3ca9

URL: https://github.com/llvm/llvm-project/commit/06cf0ce90a8f5862e9a7560a422ddea171ac3ca9
DIFF: https://github.com/llvm/llvm-project/commit/06cf0ce90a8f5862e9a7560a422ddea171ac3ca9.diff

LOG: [libc++] Enable move semantics for vector in C++03

We require move semantics in C++03 anyways, so let's enable them for the containers.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D123802

Added: 
    

Modified: 
    libcxx/include/__iterator/move_iterator.h
    libcxx/include/__utility/move.h
    libcxx/include/vector
    libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
    libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
    libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
    libcxx/test/support/MoveOnly.h
    libcxx/test/support/test_allocator.h

Removed: 
    


################################################################################
diff  --git a/libcxx/include/__iterator/move_iterator.h b/libcxx/include/__iterator/move_iterator.h
index b40e650a484d..5beb8319d172 100644
--- a/libcxx/include/__iterator/move_iterator.h
+++ b/libcxx/include/__iterator/move_iterator.h
@@ -79,17 +79,12 @@ class _LIBCPP_TEMPLATE_VIS move_iterator
     typedef typename iterator_traits<iterator_type>::
diff erence_type 
diff erence_type;
     typedef iterator_type pointer;
 
-#ifndef _LIBCPP_CXX03_LANG
     typedef typename iterator_traits<iterator_type>::reference __reference;
     typedef typename conditional<
             is_reference<__reference>::value,
             typename remove_reference<__reference>::type&&,
             __reference
         >::type reference;
-#else
-    typedef typename iterator_traits<iterator_type>::reference reference;
-#endif
-
 #endif // _LIBCPP_STD_VER > 17
 
 #if _LIBCPP_STD_VER > 17

diff  --git a/libcxx/include/__utility/move.h b/libcxx/include/__utility/move.h
index 7d1c8c2522ad..da0d986093d6 100644
--- a/libcxx/include/__utility/move.h
+++ b/libcxx/include/__utility/move.h
@@ -26,15 +26,10 @@ move(_Tp&& __t) _NOEXCEPT {
   return static_cast<_Up&&>(__t);
 }
 
-#ifndef _LIBCPP_CXX03_LANG
 template <class _Tp>
 using __move_if_noexcept_result_t =
     typename conditional<!is_nothrow_move_constructible<_Tp>::value && is_copy_constructible<_Tp>::value, const _Tp&,
                          _Tp&&>::type;
-#else // _LIBCPP_CXX03_LANG
-template <class _Tp>
-using __move_if_noexcept_result_t = const _Tp&;
-#endif
 
 template <class _Tp>
 _LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __move_if_noexcept_result_t<_Tp>

diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 07c7476cfeb3..5238ac58481d 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -434,10 +434,15 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     vector(initializer_list<value_type> __il, const allocator_type& __a);
 
+    _LIBCPP_INLINE_VISIBILITY
+    vector& operator=(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end()); return *this;}
+#endif // !_LIBCPP_CXX03_LANG
+
     _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __x)
 #if _LIBCPP_STD_VER > 14
-        _NOEXCEPT;
+        noexcept;
 #else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
 #endif
@@ -448,12 +453,6 @@ public:
     vector& operator=(vector&& __x)
         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 
-    _LIBCPP_INLINE_VISIBILITY
-    vector& operator=(initializer_list<value_type> __il)
-        {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
     template <class _InputIterator>
         typename enable_if
         <
@@ -565,41 +564,26 @@ public:
     const value_type* data() const _NOEXCEPT
         {return _VSTD::__to_address(this->__begin_);}
 
-#ifdef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
-    void __emplace_back(const value_type& __x) { push_back(__x); }
-#else
-    template <class _Arg>
-    _LIBCPP_INLINE_VISIBILITY
-    void __emplace_back(_Arg&& __arg) {
-      emplace_back(_VSTD::forward<_Arg>(__arg));
-    }
-#endif
-
     _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
 
-#ifndef _LIBCPP_CXX03_LANG
     _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
 
     template <class... _Args>
-        _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY
 #if _LIBCPP_STD_VER > 14
         reference emplace_back(_Args&&... __args);
 #else
         void      emplace_back(_Args&&... __args);
 #endif
-#endif // !_LIBCPP_CXX03_LANG
 
     _LIBCPP_INLINE_VISIBILITY
     void pop_back();
 
     iterator insert(const_iterator __position, const_reference __x);
 
-#ifndef _LIBCPP_CXX03_LANG
     iterator insert(const_iterator __position, value_type&& __x);
     template <class... _Args>
-        iterator emplace(const_iterator __position, _Args&&... __args);
-#endif // !_LIBCPP_CXX03_LANG
+    iterator emplace(const_iterator __position, _Args&&... __args);
 
     iterator insert(const_iterator __position, size_type __n, const_reference __x);
     template <class _InputIterator>
@@ -724,7 +708,6 @@ private:
         __annotate_shrink(__old_size);
     }
 
-#ifndef _LIBCPP_CXX03_LANG
     template <class _Up>
     _LIBCPP_INLINE_VISIBILITY
     inline void __push_back_slow_path(_Up&& __x);
@@ -732,11 +715,6 @@ private:
     template <class... _Args>
     _LIBCPP_INLINE_VISIBILITY
     inline void __emplace_back_slow_path(_Args&&... __args);
-#else
-    template <class _Up>
-    _LIBCPP_INLINE_VISIBILITY
-    inline void __push_back_slow_path(_Up& __x);
-#endif
 
     // The following functions are no-ops outside of AddressSanitizer mode.
     // We call annotatations only for the default Allocator because other allocators
@@ -1110,7 +1088,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
 {
     _VSTD::__debug_db_insert_c(this);
     for (; __first != __last; ++__first)
-        __emplace_back(*__first);
+        emplace_back(*__first);
 }
 
 template <class _Tp, class _Allocator>
@@ -1125,7 +1103,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
 {
     _VSTD::__debug_db_insert_c(this);
     for (; __first != __last; ++__first)
-        __emplace_back(*__first);
+        emplace_back(*__first);
 }
 
 template <class _Tp, class _Allocator>
@@ -1190,13 +1168,11 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<alloc
     }
 }
 
-#ifndef _LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(vector&& __x)
 #if _LIBCPP_STD_VER > 14
-        _NOEXCEPT
+        noexcept
 #else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
 #endif
@@ -1231,6 +1207,8 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
     }
 }
 
+#ifndef _LIBCPP_CXX03_LANG
+
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
@@ -1256,6 +1234,8 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
     }
 }
 
+#endif // _LIBCPP_CXX03_LANG
+
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>&
@@ -1295,8 +1275,6 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
     std::__debug_db_swap(this, std::addressof(__c));
 }
 
-#endif // !_LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>&
@@ -1325,7 +1303,7 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
 {
     clear();
     for (; __first != __last; ++__first)
-        __emplace_back(*__first);
+        emplace_back(*__first);
 }
 
 template <class _Tp, class _Allocator>
@@ -1519,11 +1497,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 template <class _Tp, class _Allocator>
 template <class _Up>
 void
-#ifndef _LIBCPP_CXX03_LANG
 vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
-#else
-vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x)
-#endif
 {
     allocator_type& __a = this->__alloc();
     __split_buffer<value_type, allocator_type&> __v(__recommend(size() + 1), size(), __a);
@@ -1546,8 +1520,6 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
         __push_back_slow_path(__x);
 }
 
-#ifndef _LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY
 void
@@ -1595,8 +1567,6 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 #endif
 }
 
-#endif // !_LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 inline
 void
@@ -1693,8 +1663,6 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
     return __make_iter(__p);
 }
 
-#ifndef _LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
@@ -1755,8 +1723,6 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
     return __make_iter(__p);
 }
 
-#endif // !_LIBCPP_CXX03_LANG
-
 template <class _Tp, class _Allocator>
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
@@ -2125,10 +2091,16 @@ public:
     vector(initializer_list<value_type> __il);
     vector(initializer_list<value_type> __il, const allocator_type& __a);
 
+    _LIBCPP_INLINE_VISIBILITY
+    vector& operator=(initializer_list<value_type> __il)
+        {assign(__il.begin(), __il.end()); return *this;}
+
+#endif // !_LIBCPP_CXX03_LANG
+
     _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __v)
 #if _LIBCPP_STD_VER > 14
-        _NOEXCEPT;
+        noexcept;
 #else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
 #endif
@@ -2137,12 +2109,6 @@ public:
     vector& operator=(vector&& __v)
         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 
-    _LIBCPP_INLINE_VISIBILITY
-    vector& operator=(initializer_list<value_type> __il)
-        {assign(__il.begin(), __il.end()); return *this;}
-
-#endif // !_LIBCPP_CXX03_LANG
-
     template <class _InputIterator>
         typename enable_if
         <
@@ -2739,8 +2705,6 @@ vector<bool, _Allocator>::operator=(const vector& __v)
     return *this;
 }
 
-#ifndef _LIBCPP_CXX03_LANG
-
 template <class _Allocator>
 inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
 #if _LIBCPP_STD_VER > 14
@@ -2812,8 +2776,6 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
     __c.__cap() = __c.__size_ = 0;
 }
 
-#endif // !_LIBCPP_CXX03_LANG
-
 template <class _Allocator>
 void
 vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)

diff  --git a/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp b/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
index 4961fe52f328..9e7b456bce18 100644
--- a/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
+++ b/libcxx/test/std/containers/sequences/array/array.creation/to_array.fail.cpp
@@ -28,14 +28,14 @@ int main(int, char**) {
   {
     MoveOnly mo[] = {MoveOnly{3}};
     // expected-error at array:* {{to_array requires copy constructible elements}}
-    // expected-error at array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
+    // expected-error-re at array:* {{{{(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
     std::to_array(mo); // expected-note {{requested here}}
   }
 
   {
     const MoveOnly cmo[] = {MoveOnly{3}};
     // expected-error at array:* {{to_array requires move constructible elements}}
-    // expected-error at array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
+    // expected-error-re at array:* {{{{(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
     std::to_array(std::move(cmo)); // expected-note {{requested here}}
   }
 

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
index 4d8138019106..3e25dc931f8f 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -78,8 +78,8 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(l2));
     }
     {
-        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
-        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
         assert(is_contiguous_container_asan_correct(l));
         assert(is_contiguous_container_asan_correct(lo));
         for (int i = 1; i <= 3; ++i)
@@ -89,7 +89,7 @@ int main(int, char**)
         }
         assert(is_contiguous_container_asan_correct(l));
         assert(is_contiguous_container_asan_correct(lo));
-        std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l2((min_allocator<MoveOnly>()));
         l2 = std::move(l);
         assert(l2 == lo);
         assert(l.empty());

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
index 65046a4aec34..913010435d11 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.move_only.verify.cpp
@@ -8,20 +8,15 @@
 
 // Make sure that a std::vector containing move-only types can't be copied.
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 #include <vector>
 
-struct move_only
-{
-    move_only() = default;
-    move_only(move_only&&) = default;
-    move_only& operator=(move_only&&) = default;
-};
+#include "MoveOnly.h"
 
 int main(int, char**)
 {
-    std::vector<move_only> v;
-    std::vector<move_only> copy = v; // expected-error-re@* {{{{(no matching function for call to 'construct_at')|(call to implicitly-deleted copy constructor of 'move_only')}}}}
+    std::vector<MoveOnly> v;
+    std::vector<MoveOnly> copy = v; // expected-error-re@* {{{{(no matching function for call to 'construct_at')|(call to implicitly-deleted copy constructor of 'MoveOnly')|(call to deleted constructor of 'MoveOnly')}}}}
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
index cae17b3550dd..05b29c423ce2 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -21,11 +21,11 @@
 
 void test() {
   {
-    std::vector<operator_hijacker> vo{};
-    std::vector<operator_hijacker> v{std::move(vo)};
+    std::vector<operator_hijacker> vo;
+    std::vector<operator_hijacker> v(std::move(vo));
   }
   {
-    std::vector<operator_hijacker> vo{};
-    std::vector<operator_hijacker> v{std::move(vo), std::allocator<operator_hijacker>{}};
+    std::vector<operator_hijacker> vo;
+    std::vector<operator_hijacker> v(std::move(vo), std::allocator<operator_hijacker>());
   }
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
index 8c797d1a7cbe..046f09fd4967 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -72,8 +72,8 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(c2));
     }
     {
-        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
-        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
         assert(is_contiguous_container_asan_correct(l));
         assert(is_contiguous_container_asan_correct(lo));
         for (int i = 1; i <= 3; ++i)
@@ -91,12 +91,12 @@ int main(int, char**)
     }
     {
         int a1[] = {1, 3, 7, 9, 10};
-        std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+        std::vector<int, min_allocator<int> > c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
         assert(is_contiguous_container_asan_correct(c1));
-        std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
-        std::vector<int, min_allocator<int>> c2 = std::move(c1);
+        std::vector<int, min_allocator<int> >::const_iterator i = c1.begin();
+        std::vector<int, min_allocator<int> > c2 = std::move(c1);
         assert(is_contiguous_container_asan_correct(c2));
-        std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+        std::vector<int, min_allocator<int> >::iterator j = c2.erase(i);
         assert(*j == 3);
         assert(is_contiguous_container_asan_correct(c2));
     }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
index b5292110cc94..3f6b3fe425ab 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -77,8 +77,8 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(l2));
     }
     {
-        std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
-        std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+        std::vector<MoveOnly, min_allocator<MoveOnly> > l((min_allocator<MoveOnly>()));
+        std::vector<MoveOnly, min_allocator<MoveOnly> > lo((min_allocator<MoveOnly>()));
         assert(is_contiguous_container_asan_correct(l));
         assert(is_contiguous_container_asan_correct(lo));
         for (int i = 1; i <= 3; ++i)

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
index 0875705a4c42..43e553e71e74 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
index cc55967ae5f4..bc85f3e2969a 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -109,8 +109,8 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(c));
     }
     {
-        std::vector<A, min_allocator<A>> c;
-        std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+        std::vector<A, min_allocator<A> > c;
+        std::vector<A, min_allocator<A> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
         assert(i == c.begin());
         assert(c.size() == 1);
         assert(c.front().geti() == 2);

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
index c375933adda5..5cf38f2f440f 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -26,9 +26,10 @@ class A
     int i_;
     double d_;
 
-    A(const A&);
-    A& operator=(const A&);
 public:
+    A(const A&) = delete;
+    A& operator=(const A&) = delete;
+
     A(int i, double d)
         : i_(i), d_(d) {}
 
@@ -110,7 +111,7 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(c));
     }
     {
-        std::vector<A, min_allocator<A>> c;
+        std::vector<A, min_allocator<A> > c;
 #if TEST_STD_VER > 14
         A& r1 = c.emplace_back(2, 3.5);
         assert(c.size() == 1);
@@ -137,7 +138,7 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(c));
     }
     {
-        std::vector<Tag_X, TaggingAllocator<Tag_X>> c;
+        std::vector<Tag_X, TaggingAllocator<Tag_X> > c;
         c.emplace_back();
         assert(c.size() == 1);
         c.emplace_back(1, 2, 3);

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
index ba497779a967..11f24604eeac 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -21,5 +21,5 @@
 
 void test() {
   std::vector<operator_hijacker> v;
-  v.insert(v.end(), operator_hijacker{});
+  v.insert(v.end(), operator_hijacker());
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
index 13c6681678da..fe03f2acfab2 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -50,8 +50,8 @@ int main(int, char**)
             assert(v[j] == MoveOnly());
     }
     {
-        std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
-        std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+        std::vector<MoveOnly, min_allocator<MoveOnly> > v(100);
+        std::vector<MoveOnly, min_allocator<MoveOnly> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
         assert(v.size() == 101);
         assert(is_contiguous_container_asan_correct(v));
         assert(i == v.begin() + 10);

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
index c8e816a31ef9..e7527d44ca47 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -83,7 +83,7 @@ int main(int, char**)
             assert(c[j] == MoveOnly(j));
     }
     {
-        std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+        std::vector<MoveOnly, min_allocator<MoveOnly> > c;
         c.push_back(MoveOnly(0));
         assert(c.size() == 1);
         assert(is_contiguous_container_asan_correct(c));

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
index ea74afcd619a..0ee39f3332b2 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
+// UNSUPPORTED: c++03 && !stdlib=libc++
 
 // <vector>
 
@@ -40,7 +40,7 @@ int main(int, char**) {
     x.emplace_back();
   }
   {
-    std::vector<BadUserNoCookie<2>> x;
+    std::vector<BadUserNoCookie<2> > x;
     BadUserNoCookie<2> c;
     x.push_back(c);
   }

diff  --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
index 1bee8dbf6fb7..2d0dadfeec8f 100644
--- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
+++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/types.pass.cpp
@@ -49,11 +49,7 @@ test()
     static_assert((std::is_same<typename R::
diff erence_type, typename T::
diff erence_type>::value), "");
     static_assert((std::is_same<typename R::pointer, It>::value), "");
     static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
-#if TEST_STD_VER >= 11
     static_assert((std::is_same<typename R::reference, typename R::value_type&&>::value), "");
-#else
-    static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
-#endif
 #if TEST_STD_VER > 17
     if constexpr (std::is_same_v<typename T::iterator_category, std::contiguous_iterator_tag>) {
         static_assert((std::is_same<typename R::iterator_category, std::random_access_iterator_tag>::value), "");

diff  --git a/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
index 3d7e762024cb..d3c253eb2050 100644
--- a/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
+++ b/libcxx/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp
@@ -6,6 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+// UNSUPPORTED: c++03 && !stdlib=libc++
+
 // <utility>
 
 // template <class T>
@@ -46,20 +48,11 @@ int main(int, char**)
     A a;
     const A ca;
 
-#if TEST_STD_VER >= 11
     static_assert((std::is_same<decltype(std::move_if_noexcept(i)), int&&>::value), "");
     static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&&>::value), "");
     static_assert((std::is_same<decltype(std::move_if_noexcept(a)), A&&>::value), "");
     static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&&>::value), "");
     static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
-#else  // C++ < 11
-    // In C++03 we don't have noexcept so we can never move :-(
-    static_assert((std::is_same<decltype(std::move_if_noexcept(i)), const int&>::value), "");
-    static_assert((std::is_same<decltype(std::move_if_noexcept(ci)), const int&>::value), "");
-    static_assert((std::is_same<decltype(std::move_if_noexcept(a)), const A&>::value), "");
-    static_assert((std::is_same<decltype(std::move_if_noexcept(ca)), const A&>::value), "");
-    static_assert((std::is_same<decltype(std::move_if_noexcept(l)), const legacy&>::value), "");
-#endif
 
 #if TEST_STD_VER > 11
     constexpr int i1 = 23;

diff  --git a/libcxx/test/support/MoveOnly.h b/libcxx/test/support/MoveOnly.h
index 33557773e919..4178b55e6f41 100644
--- a/libcxx/test/support/MoveOnly.h
+++ b/libcxx/test/support/MoveOnly.h
@@ -11,8 +11,6 @@
 
 #include "test_macros.h"
 
-#if TEST_STD_VER >= 11
-
 #include <cstddef>
 #include <functional>
 
@@ -20,31 +18,35 @@ class MoveOnly
 {
     int data_;
 public:
-    constexpr MoveOnly(int data = 1) : data_(data) {}
+    TEST_CONSTEXPR MoveOnly(int data = 1) : data_(data) {}
+
+    MoveOnly(const MoveOnly&) = delete;
+    MoveOnly& operator=(const MoveOnly&) = delete;
+
     TEST_CONSTEXPR_CXX14 MoveOnly(MoveOnly&& x)
         : data_(x.data_) {x.data_ = 0;}
     TEST_CONSTEXPR_CXX14 MoveOnly& operator=(MoveOnly&& x)
         {data_ = x.data_; x.data_ = 0; return *this;}
 
-    constexpr int get() const {return data_;}
+    TEST_CONSTEXPR int get() const {return data_;}
 
-    friend constexpr bool operator==(const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator==(const MoveOnly& x, const MoveOnly& y)
         { return x.data_ == y.data_; }
-    friend constexpr bool operator!=(const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator!=(const MoveOnly& x, const MoveOnly& y)
         { return x.data_ != y.data_; }
-    friend constexpr bool operator< (const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator< (const MoveOnly& x, const MoveOnly& y)
         { return x.data_ <  y.data_; }
-    friend constexpr bool operator<=(const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator<=(const MoveOnly& x, const MoveOnly& y)
         { return x.data_ <= y.data_; }
-    friend constexpr bool operator> (const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator> (const MoveOnly& x, const MoveOnly& y)
         { return x.data_ >  y.data_; }
-    friend constexpr bool operator>=(const MoveOnly& x, const MoveOnly& y)
+    friend TEST_CONSTEXPR bool operator>=(const MoveOnly& x, const MoveOnly& y)
         { return x.data_ >= y.data_; }
 
     TEST_CONSTEXPR_CXX14 MoveOnly operator+(const MoveOnly& x) const
-        { return MoveOnly{data_ + x.data_}; }
+        { return MoveOnly(data_ + x.data_); }
     TEST_CONSTEXPR_CXX14 MoveOnly operator*(const MoveOnly& x) const
-        { return MoveOnly{data_ * x.data_}; }
+        { return MoveOnly(data_ * x.data_); }
 
     template<class T, class U>
     friend void operator,(T t, U u) = delete;
@@ -56,9 +58,7 @@ struct std::hash<MoveOnly>
 {
     typedef MoveOnly argument_type;
     typedef size_t result_type;
-    constexpr size_t operator()(const MoveOnly& x) const {return x.get();}
+    TEST_CONSTEXPR size_t operator()(const MoveOnly& x) const {return x.get();}
 };
 
-#endif // TEST_STD_VER >= 11
-
 #endif // MOVEONLY_H

diff  --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h
index b5320067ca04..741f6fc2f532 100644
--- a/libcxx/test/support/test_allocator.h
+++ b/libcxx/test/support/test_allocator.h
@@ -112,7 +112,6 @@ class test_allocator {
     }
   }
 
-#if TEST_STD_VER >= 11
   TEST_CONSTEXPR_CXX14 test_allocator(test_allocator&& a) TEST_NOEXCEPT : data_(a.data_), id_(a.id_), stats_(a.stats_) {
     if (stats_ != nullptr) {
       ++stats_->count;
@@ -123,7 +122,6 @@ class test_allocator {
     a.data_ = test_alloc_base::moved_value;
     a.id_ = test_alloc_base::moved_value;
   }
-#endif
 
   template <class U>
   TEST_CONSTEXPR_CXX14 test_allocator(const test_allocator<U>& a) TEST_NOEXCEPT
@@ -166,14 +164,11 @@ class test_allocator {
 
   TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { return UINT_MAX / sizeof(T); }
 
-#if TEST_STD_VER < 11
-  void construct(pointer p, const T& val) { ::new (static_cast<void*>(p)) T(val); }
-#else
   template <class U>
   TEST_CONSTEXPR_CXX14 void construct(pointer p, U&& val) {
     ::new (static_cast<void*>(p)) T(std::forward<U>(val));
   }
-#endif
+
   TEST_CONSTEXPR_CXX14 void destroy(pointer p) { p->~T(); }
   TEST_CONSTEXPR friend bool operator==(const test_allocator& x, const test_allocator& y) { return x.data_ == y.data_; }
   TEST_CONSTEXPR friend bool operator!=(const test_allocator& x, const test_allocator& y) { return !(x == y); }
@@ -358,8 +353,6 @@ class other_allocator {
 #endif
 };
 
-#if TEST_STD_VER >= 11
-
 struct Ctor_Tag {};
 
 template <typename T>
@@ -369,15 +362,15 @@ struct Tag_X {
   // All constructors must be passed the Tag type.
 
   // DefaultInsertable into vector<X, TaggingAllocator<X>>,
-  constexpr Tag_X(Ctor_Tag) {}
+  TEST_CONSTEXPR Tag_X(Ctor_Tag) {}
   // CopyInsertable into vector<X, TaggingAllocator<X>>,
-  constexpr Tag_X(Ctor_Tag, const Tag_X&) {}
+  TEST_CONSTEXPR Tag_X(Ctor_Tag, const Tag_X&) {}
   // MoveInsertable into vector<X, TaggingAllocator<X>>, and
-  constexpr Tag_X(Ctor_Tag, Tag_X&&) {}
+  TEST_CONSTEXPR Tag_X(Ctor_Tag, Tag_X&&) {}
 
   // EmplaceConstructible into vector<X, TaggingAllocator<X>> from args.
   template <typename... Args>
-  constexpr Tag_X(Ctor_Tag, Args&&...) {}
+  TEST_CONSTEXPR Tag_X(Ctor_Tag, Args&&...) {}
 
   // not DefaultConstructible, CopyConstructible or MoveConstructible.
   Tag_X() = delete;
@@ -403,11 +396,11 @@ class TaggingAllocator {
   TaggingAllocator() = default;
 
   template <typename U>
-  constexpr TaggingAllocator(const TaggingAllocator<U>&){};
+  TEST_CONSTEXPR TaggingAllocator(const TaggingAllocator<U>&) {}
 
   template <typename... Args>
   void construct(Tag_X* p, Args&&... args) {
-    ::new ((void*)p) Tag_X(Ctor_Tag{}, std::forward<Args>(args)...);
+    ::new ((void*)p) Tag_X(Ctor_Tag(), std::forward<Args>(args)...);
   }
 
   template <typename U>
@@ -415,10 +408,9 @@ class TaggingAllocator {
     p->~U();
   }
 
-  TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return std::allocator<T>{}.allocate(n); }
-  TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>{}.deallocate(p, n); }
+  TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return std::allocator<T>().allocate(n); }
+  TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
 };
-#endif
 
 template <std::size_t MaxAllocs>
 struct limited_alloc_handle {


        


More information about the libcxx-commits mailing list