[llvm-branch-commits] [libcxx] c74059c - [libc++] Implement P1004R2 (constexpr std::vector)

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jul 29 09:51:07 PDT 2022


Author: Nikolas Klauser
Date: 2022-07-29T09:50:29-07:00
New Revision: c74059c5da05cc6fd90afb3a5657bc12a1bb6d81

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

LOG: [libc++] Implement P1004R2 (constexpr std::vector)

Reviewed By: #libc, ldionne

Spies: mgorny, var-const, ormris, philnik, miscco, hiraditya, steven_wu, jkorous, ldionne, christof, libcxx-commits

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

(cherry picked from commit 98d3d5b5da66e3cf7807c23a0294280bb796466b)

Added: 
    libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/docs/Status/Cxx20Papers.csv
    libcxx/include/__algorithm/fill.h
    libcxx/include/__algorithm/fill_n.h
    libcxx/include/__bit_reference
    libcxx/include/__memory/construct_at.h
    libcxx/include/__memory/pointer_traits.h
    libcxx/include/__memory/uninitialized_algorithms.h
    libcxx/include/__split_buffer
    libcxx/include/memory
    libcxx/include/vector
    libcxx/src/include/sso_allocator.h
    libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp
    libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
    libcxx/test/std/containers/sequences/vector/access.pass.cpp
    libcxx/test/std/containers/sequences/vector/compare.pass.cpp
    libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp
    libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp
    libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
    libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.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.cons/move_assign_noexcept.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.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/emplace_extra.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
    libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
    libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
    libcxx/test/support/allocators.h
    libcxx/test/support/asan_testing.h
    libcxx/test/support/poisoned_hash_helper.h
    libcxx/test/support/test_allocator.h

Removed: 
    


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index 96e98fd5c9ab3..c717ea2682b54 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -50,6 +50,7 @@ almost complete. The ``ranges`` library is considered experimental.
 Implemented Papers
 ------------------
 
+- P1004R2 - Making ``std::vector`` constexpr
 - P0627R6 - Function to mark unreachable code
 - P1165R1 - Make stateful allocator propagation more consistent for ``operator+(basic_string)``
 - P0674R1 - Support arrays in ``make_shared`` and ``allocate_shared``

diff  --git a/libcxx/docs/Status/Cxx20Papers.csv b/libcxx/docs/Status/Cxx20Papers.csv
index 703c4a54c27e9..f335d1b984a25 100644
--- a/libcxx/docs/Status/Cxx20Papers.csv
+++ b/libcxx/docs/Status/Cxx20Papers.csv
@@ -107,7 +107,7 @@
 "`P0660R10 <https://wg21.link/P0660R10>`__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","",""
 "`P0784R7 <https://wg21.link/P0784R7>`__","CWG","More constexpr containers","Cologne","|Complete|","12.0"
 "`P0980R1 <https://wg21.link/P0980R1>`__","LWG","Making std::string constexpr","Cologne","|Complete|","15.0"
-"`P1004R2 <https://wg21.link/P1004R2>`__","LWG","Making std::vector constexpr","Cologne","",""
+"`P1004R2 <https://wg21.link/P1004R2>`__","LWG","Making std::vector constexpr","Cologne","|Complete|","15.0"
 "`P1035R7 <https://wg21.link/P1035R7>`__","LWG","Input Range Adaptors","Cologne","",""
 "`P1065R2 <https://wg21.link/P1065R2>`__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0"
 "`P1135R6 <https://wg21.link/P1135R6>`__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0"

diff  --git a/libcxx/include/__algorithm/fill.h b/libcxx/include/__algorithm/fill.h
index ec9968fdb8b34..901ba4e68689a 100644
--- a/libcxx/include/__algorithm/fill.h
+++ b/libcxx/include/__algorithm/fill.h
@@ -20,6 +20,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
 template <class _ForwardIterator, class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void

diff  --git a/libcxx/include/__algorithm/fill_n.h b/libcxx/include/__algorithm/fill_n.h
index 7482a4188dd51..6c5e44efde9b0 100644
--- a/libcxx/include/__algorithm/fill_n.h
+++ b/libcxx/include/__algorithm/fill_n.h
@@ -19,6 +19,8 @@
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
+// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset.
+
 template <class _OutputIterator, class _Size, class _Tp>
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 _OutputIterator

diff  --git a/libcxx/include/__bit_reference b/libcxx/include/__bit_reference
index f54cb6c16f48e..60f57d665a1cb 100644
--- a/libcxx/include/__bit_reference
+++ b/libcxx/include/__bit_reference
@@ -10,10 +10,13 @@
 #ifndef _LIBCPP___BIT_REFERENCE
 #define _LIBCPP___BIT_REFERENCE
 
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
 #include <__algorithm/min.h>
 #include <__bits>
 #include <__config>
 #include <__iterator/iterator_traits.h>
+#include <__memory/construct_at.h>
 #include <__memory/pointer_traits.h>
 #include <cstring>
 #include <type_traits>
@@ -51,15 +54,15 @@ class __bit_reference
     friend class __bit_const_reference<_Cp>;
     friend class __bit_iterator<_Cp, false>;
 public:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_reference(const __bit_reference&) = default;
 
-    _LIBCPP_INLINE_VISIBILITY operator bool() const _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 operator bool() const _NOEXCEPT
         {return static_cast<bool>(*__seg_ & __mask_);}
-    _LIBCPP_INLINE_VISIBILITY bool operator ~() const _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool operator ~() const _NOEXCEPT
         {return !static_cast<bool>(*this);}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_reference& operator=(bool __x) _NOEXCEPT
     {
         if (__x)
@@ -70,7 +73,7 @@ public:
     }
 
 #if _LIBCPP_STD_VER > 20
-    _LIBCPP_HIDE_FROM_ABI const __bit_reference& operator=(bool __x) const noexcept {
+    _LIBCPP_HIDE_FROM_ABI constexpr const __bit_reference& operator=(bool __x) const noexcept {
         if (__x)
             *__seg_ |= __mask_;
         else
@@ -79,15 +82,15 @@ public:
     }
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_reference& operator=(const __bit_reference& __x) _NOEXCEPT
         {return operator=(static_cast<bool>(__x));}
 
-    _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
         {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
 private:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     explicit __bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
         : __seg_(__s), __mask_(__m) {}
 };
@@ -98,7 +101,7 @@ class __bit_reference<_Cp, false>
 };
 
 template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
 {
@@ -108,7 +111,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
 }
 
 template <class _Cp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
 {
@@ -118,7 +121,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT
 }
 
 template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
 {
@@ -128,7 +131,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT
 }
 
 template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT
 {
@@ -152,14 +155,14 @@ public:
     _LIBCPP_INLINE_VISIBILITY
     __bit_const_reference(const __bit_const_reference&) = default;
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_const_reference(const __bit_reference<_Cp>& __x) _NOEXCEPT
         : __seg_(__x.__seg_), __mask_(__x.__mask_) {}
 
     _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR operator bool() const _NOEXCEPT
         {return static_cast<bool>(*__seg_ & __mask_);}
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
         {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
 private:
     _LIBCPP_INLINE_VISIBILITY
@@ -173,12 +176,12 @@ private:
 // find
 
 template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
 __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
 {
     typedef __bit_iterator<_Cp, _IsConst> _It;
     typedef typename _It::__storage_type __storage_type;
-    static const int __bits_per_word = _It::__bits_per_word;
+    const int __bits_per_word = _It::__bits_per_word;
     // do first partial word
     if (__first.__ctz_ != 0)
     {
@@ -209,7 +212,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
 }
 
 template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, _IsConst>
 __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type __n)
 {
     typedef __bit_iterator<_Cp, _IsConst> _It;
@@ -248,7 +251,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
 }
 
 template <class _Cp, bool _IsConst, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 __bit_iterator<_Cp, _IsConst>
 find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value)
 {
@@ -334,7 +337,7 @@ count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __las
 // fill_n
 
 template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
 {
     typedef __bit_iterator<_Cp, false> _It;
@@ -352,7 +355,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
     }
     // do middle whole words
     __storage_type __nw = __n / __bits_per_word;
-    _VSTD::memset(_VSTD::__to_address(__first.__seg_), 0, __nw * sizeof(__storage_type));
+    std::fill_n(std::__to_address(__first.__seg_), __nw, 0);
     __n -= __nw * __bits_per_word;
     // do last partial word
     if (__n > 0)
@@ -364,7 +367,7 @@ __fill_n_false(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
 }
 
 template <class _Cp>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
 {
     typedef __bit_iterator<_Cp, false> _It;
@@ -382,7 +385,8 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
     }
     // do middle whole words
     __storage_type __nw = __n / __bits_per_word;
-    _VSTD::memset(_VSTD::__to_address(__first.__seg_), -1, __nw * sizeof(__storage_type));
+    // __storage_type is always an unsigned type, so -1 sets all bits
+    std::fill_n(std::__to_address(__first.__seg_), __nw, static_cast<__storage_type>(-1));
     __n -= __nw * __bits_per_word;
     // do last partial word
     if (__n > 0)
@@ -394,7 +398,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n)
 }
 
 template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value)
 {
@@ -410,7 +414,7 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v
 // fill
 
 template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool __value)
 {
@@ -420,6 +424,7 @@ fill(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __last, bool
 // copy
 
 template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __bit_iterator<_Cp, false>
 __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
                                                      __bit_iterator<_Cp, false> __result)
@@ -449,9 +454,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
         // __first.__ctz_ == 0;
         // do middle words
         __storage_type __nw = __n / __bits_per_word;
-        _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
-                       _VSTD::__to_address(__first.__seg_),
-                       __nw * sizeof(__storage_type));
+        std::copy_n(std::__to_address(__first.__seg_), __nw, std::__to_address(__result.__seg_));
         __n -= __nw * __bits_per_word;
         __result.__seg_ += __nw;
         // do last word
@@ -469,6 +472,7 @@ __copy_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsCon
 }
 
 template <class _Cp, bool _IsConst>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __bit_iterator<_Cp, false>
 __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
                                                        __bit_iterator<_Cp, false> __result)
@@ -476,7 +480,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
     typedef __bit_iterator<_Cp, _IsConst> _In;
     typedef  typename _In::
diff erence_type 
diff erence_type;
     typedef typename _In::__storage_type __storage_type;
-    static const int __bits_per_word = _In::__bits_per_word;
+    const int __bits_per_word = _In::__bits_per_word;
     
diff erence_type __n = __last - __first;
     if (__n > 0)
     {
@@ -547,7 +551,7 @@ __copy_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsC
 }
 
 template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 __bit_iterator<_Cp, false>
 copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
 {
@@ -559,7 +563,7 @@ copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last
 // copy_backward
 
 template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
 __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
                                                      __bit_iterator<_Cp, false> __result)
 {
@@ -590,9 +594,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
         __storage_type __nw = __n / __bits_per_word;
         __result.__seg_ -= __nw;
         __last.__seg_ -= __nw;
-        _VSTD::memmove(_VSTD::__to_address(__result.__seg_),
-                       _VSTD::__to_address(__last.__seg_),
-                       __nw * sizeof(__storage_type));
+        std::copy_n(std::__to_address(__last.__seg_), __nw, std::__to_address(__result.__seg_));
         __n -= __nw * __bits_per_word;
         // do last word
         if (__n > 0)
@@ -608,7 +610,7 @@ __copy_backward_aligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_C
 }
 
 template <class _Cp, bool _IsConst>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
 __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last,
                                                        __bit_iterator<_Cp, false> __result)
 {
@@ -694,7 +696,7 @@ __copy_backward_unaligned(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<
 }
 
 template <class _Cp, bool _IsConst>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 __bit_iterator<_Cp, false>
 copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result)
 {
@@ -901,14 +903,19 @@ struct __bit_array
     
diff erence_type __size_;
     __storage_type __word_[_Np];
 
-    _LIBCPP_INLINE_VISIBILITY static 
diff erence_type capacity()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 static 
diff erence_type capacity()
         {return static_cast<
diff erence_type>(_Np * __bits_per_word);}
-    _LIBCPP_INLINE_VISIBILITY explicit __bit_array(
diff erence_type __s) : __size_(__s) {}
-    _LIBCPP_INLINE_VISIBILITY iterator begin()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit __bit_array(
diff erence_type __s) : __size_(__s) {
+        if (__libcpp_is_constant_evaluated()) {
+            for (size_t __i = 0; __i != __bit_array<_Cp>::_Np; ++__i)
+                std::__construct_at(__word_ + __i, 0);
+        }
+    }
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator begin()
     {
         return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]), 0);
     }
-    _LIBCPP_INLINE_VISIBILITY iterator end()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator end()
     {
         return iterator(pointer_traits<__storage_pointer>::pointer_to(__word_[0]) + __size_ / __bits_per_word,
                                                   static_cast<unsigned>(__size_ % __bits_per_word));
@@ -916,7 +923,7 @@ struct __bit_array
 };
 
 template <class _Cp>
-__bit_iterator<_Cp, false>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator<_Cp, false>
 rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle, __bit_iterator<_Cp, false> __last)
 {
     typedef __bit_iterator<_Cp, false> _I1;
@@ -967,14 +974,14 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
 // equal
 
 template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
                   __bit_iterator<_Cp, _IC2> __first2)
 {
     typedef __bit_iterator<_Cp, _IC1> _It;
     typedef  typename _It::
diff erence_type 
diff erence_type;
     typedef typename _It::__storage_type __storage_type;
-    static const int __bits_per_word = _It::__bits_per_word;
+    const int __bits_per_word = _It::__bits_per_word;
     
diff erence_type __n = __last1 - __first1;
     if (__n > 0)
     {
@@ -1049,14 +1056,14 @@ __equal_unaligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1>
 }
 
 template <class _Cp, bool _IC1, bool _IC2>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1,
                 __bit_iterator<_Cp, _IC2> __first2)
 {
     typedef __bit_iterator<_Cp, _IC1> _It;
     typedef  typename _It::
diff erence_type 
diff erence_type;
     typedef typename _It::__storage_type __storage_type;
-    static const int __bits_per_word = _It::__bits_per_word;
+    const int __bits_per_word = _It::__bits_per_word;
     
diff erence_type __n = __last1 - __first1;
     if (__n > 0)
     {
@@ -1092,7 +1099,7 @@ __equal_aligned(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __
 }
 
 template <class _Cp, bool _IC1, bool _IC2>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2)
 {
@@ -1126,7 +1133,7 @@ private:
     unsigned          __ctz_;
 
 public:
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator() _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator() _NOEXCEPT
 #if _LIBCPP_STD_VER > 11
     : __seg_(nullptr), __ctz_(0)
 #endif
@@ -1137,7 +1144,7 @@ public:
     // When _IsConst=true, this is a converting constructor;
     // the copy and move constructors are implicitly generated
     // and trivial.
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT
         : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {}
 
@@ -1146,19 +1153,19 @@ public:
     // the implicit generation of a defaulted one is deprecated.
     // When _IsConst=true, the assignment operators are
     // implicitly generated and trivial.
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) {
         __seg_ = __it.__seg_;
         __ctz_ = __it.__ctz_;
         return *this;
     }
 
-    _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT {
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator*() const _NOEXCEPT {
         return typename conditional<_IsConst, __bit_const_reference<_Cp>, __bit_reference<_Cp> >
                 ::type(__seg_, __storage_type(1) << __ctz_);
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator++()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator++()
     {
         if (__ctz_ != __bits_per_word-1)
             ++__ctz_;
@@ -1170,14 +1177,14 @@ public:
         return *this;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator++(int)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator++(int)
     {
         __bit_iterator __tmp = *this;
         ++(*this);
         return __tmp;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator--()
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator--()
     {
         if (__ctz_ != 0)
             --__ctz_;
@@ -1189,14 +1196,14 @@ public:
         return *this;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator--(int)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator--(int)
     {
         __bit_iterator __tmp = *this;
         --(*this);
         return __tmp;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator+=(
diff erence_type __n)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator+=(
diff erence_type __n)
     {
         if (__n >= 0)
             __seg_ += (__n + __ctz_) / __bits_per_word;
@@ -1208,54 +1215,54 @@ public:
         return *this;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator& operator-=(
diff erence_type __n)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator& operator-=(
diff erence_type __n)
     {
         return *this += -__n;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator+(
diff erence_type __n) const
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator+(
diff erence_type __n) const
     {
         __bit_iterator __t(*this);
         __t += __n;
         return __t;
     }
 
-    _LIBCPP_INLINE_VISIBILITY __bit_iterator operator-(
diff erence_type __n) const
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 __bit_iterator operator-(
diff erence_type __n) const
     {
         __bit_iterator __t(*this);
         __t -= __n;
         return __t;
     }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     friend __bit_iterator operator+(
diff erence_type __n, const __bit_iterator& __it) {return __it + __n;}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     friend 
diff erence_type operator-(const __bit_iterator& __x, const __bit_iterator& __y)
         {return (__x.__seg_ - __y.__seg_) * __bits_per_word + __x.__ctz_ - __y.__ctz_;}
 
-    _LIBCPP_INLINE_VISIBILITY reference operator[](
diff erence_type __n) const {return *(*this + __n);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference operator[](
diff erence_type __n) const {return *(*this + __n);}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator==(const __bit_iterator& __x, const __bit_iterator& __y)
         {return __x.__seg_ == __y.__seg_ && __x.__ctz_ == __y.__ctz_;}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator!=(const __bit_iterator& __x, const __bit_iterator& __y)
         {return !(__x == __y);}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<(const __bit_iterator& __x, const __bit_iterator& __y)
         {return __x.__seg_ < __y.__seg_ || (__x.__seg_ == __y.__seg_ && __x.__ctz_ < __y.__ctz_);}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>(const __bit_iterator& __x, const __bit_iterator& __y)
         {return __y < __x;}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator<=(const __bit_iterator& __x, const __bit_iterator& __y)
         {return !(__y < __x);}
 
-    _LIBCPP_INLINE_VISIBILITY friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 friend bool operator>=(const __bit_iterator& __x, const __bit_iterator& __y)
         {return !(__x < __y);}
 
 private:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     explicit __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT
         : __seg_(__s), __ctz_(__ctz) {}
 
@@ -1265,26 +1272,44 @@ private:
     friend class __bit_const_reference<_Cp>;
     friend class __bit_iterator<_Cp, true>;
     template <class _Dp> friend struct __bit_array;
-    template <class _Dp> friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
-    template <class _Dp> friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
-                                                                                  __bit_iterator<_Dp, _IC> __last,
-                                                                                  __bit_iterator<_Dp, false> __result);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
-                                                                                    __bit_iterator<_Dp, _IC> __last,
-                                                                                    __bit_iterator<_Dp, false> __result);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
-                                                                        __bit_iterator<_Dp, _IC> __last,
-                                                                        __bit_iterator<_Dp, false> __result);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
-                                                                                           __bit_iterator<_Dp, _IC> __last,
-                                                                                           __bit_iterator<_Dp, false> __result);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
-                                                                                             __bit_iterator<_Dp, _IC> __last,
-                                                                                             __bit_iterator<_Dp, false> __result);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
-                                                                                 __bit_iterator<_Dp, _IC> __last,
-                                                                                 __bit_iterator<_Dp, false> __result);
+    template <class _Dp>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend void __fill_n_false(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+    template <class _Dp>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend void __fill_n_true(__bit_iterator<_Dp, false> __first, typename _Dp::size_type __n);
+
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> __copy_aligned(__bit_iterator<_Dp, _IC> __first,
+                                                     __bit_iterator<_Dp, _IC> __last,
+                                                     __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> __copy_unaligned(__bit_iterator<_Dp, _IC> __first,
+                                                       __bit_iterator<_Dp, _IC> __last,
+                                                       __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> copy(__bit_iterator<_Dp, _IC> __first,
+                                           __bit_iterator<_Dp, _IC> __last,
+                                           __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> __copy_backward_aligned(__bit_iterator<_Dp, _IC> __first,
+                                                              __bit_iterator<_Dp, _IC> __last,
+                                                              __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> __copy_backward_unaligned(__bit_iterator<_Dp, _IC> __first,
+                                                                __bit_iterator<_Dp, _IC> __last,
+                                                                __bit_iterator<_Dp, false> __result);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> copy_backward(__bit_iterator<_Dp, _IC> __first,
+                                                    __bit_iterator<_Dp, _IC> __last,
+                                                    __bit_iterator<_Dp, false> __result);
     template <class __C1, class __C2>friend __bit_iterator<__C2, false> __swap_ranges_aligned(__bit_iterator<__C1, false>,
                                                                                            __bit_iterator<__C1, false>,
                                                                                            __bit_iterator<__C2, false>);
@@ -1294,22 +1319,32 @@ private:
     template <class __C1, class __C2>friend __bit_iterator<__C2, false> swap_ranges(__bit_iterator<__C1, false>,
                                                                                  __bit_iterator<__C1, false>,
                                                                                  __bit_iterator<__C2, false>);
-    template <class _Dp> friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
-                                                                __bit_iterator<_Dp, false>,
-                                                                __bit_iterator<_Dp, false>);
-    template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
-                                                    __bit_iterator<_Dp, _IC1>,
-                                                    __bit_iterator<_Dp, _IC2>);
-    template <class _Dp, bool _IC1, bool _IC2> friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
-                                                      __bit_iterator<_Dp, _IC1>,
-                                                      __bit_iterator<_Dp, _IC2>);
-    template <class _Dp, bool _IC1, bool _IC2> friend bool equal(__bit_iterator<_Dp, _IC1>,
-                                                                __bit_iterator<_Dp, _IC1>,
-                                                                __bit_iterator<_Dp, _IC2>);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>,
-                                                                          typename _Dp::size_type);
-    template <class _Dp, bool _IC> friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>,
-                                                                           typename _Dp::size_type);
+    template <class _Dp>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, false> rotate(__bit_iterator<_Dp, false>,
+                                             __bit_iterator<_Dp, false>,
+                                             __bit_iterator<_Dp, false>);
+    template <class _Dp, bool _IC1, bool _IC2>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend bool __equal_aligned(__bit_iterator<_Dp, _IC1>,
+                                __bit_iterator<_Dp, _IC1>,
+                                __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC1, bool _IC2>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend bool __equal_unaligned(__bit_iterator<_Dp, _IC1>,
+                                  __bit_iterator<_Dp, _IC1>,
+                                  __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC1, bool _IC2>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend bool equal(__bit_iterator<_Dp, _IC1>,
+                      __bit_iterator<_Dp, _IC1>,
+                      __bit_iterator<_Dp, _IC2>);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, _IC> __find_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
+    template <class _Dp, bool _IC>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
+    friend __bit_iterator<_Dp, _IC> __find_bool_false(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
     template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::
diff erence_type
                    __count_bool_true(__bit_iterator<_Dp, _IC>, typename _Dp::size_type);
     template <class _Dp, bool _IC> friend typename __bit_iterator<_Dp, _IC>::
diff erence_type

diff  --git a/libcxx/include/__memory/construct_at.h b/libcxx/include/__memory/construct_at.h
index bfa20a149d51c..f5985b7731fda 100644
--- a/libcxx/include/__memory/construct_at.h
+++ b/libcxx/include/__memory/construct_at.h
@@ -42,7 +42,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp* __construct_at(_Tp* __location, _Ar
 #if _LIBCPP_STD_VER > 17
   return std::construct_at(__location, std::forward<_Args>(__args)...);
 #else
-  return ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
+  return _LIBCPP_ASSERT(__location != nullptr, "null pointer given to construct_at"),
+         ::new (std::__voidify(*__location)) _Tp(std::forward<_Args>(__args)...);
 #endif
 }
 

diff  --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 2549e4be7df12..c4cd56a21feab 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -122,7 +122,7 @@ struct _LIBCPP_TEMPLATE_VIS pointer_traits
 private:
     struct __nat {};
 public:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     static pointer pointer_to(typename conditional<is_void<element_type>::value,
                                            __nat, element_type>::type& __r)
         {return pointer::pointer_to(__r);}

diff  --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 72b6890c22251..4f3d4e90cb6e2 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -509,10 +509,11 @@ __allocator_destroy(_Alloc& __alloc, _Iter __first, _Sent __last) {
 template <class _Alloc, class _Iter>
 class _AllocatorDestroyRangeReverse {
 public:
-  _LIBCPP_HIDE_FROM_ABI _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+  _AllocatorDestroyRangeReverse(_Alloc& __alloc, _Iter& __first, _Iter& __last)
       : __alloc_(__alloc), __first_(__first), __last_(__last) {}
 
-  _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
+  _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11 void operator()() const {
     std::__allocator_destroy(__alloc_, std::reverse_iterator<_Iter>(__last_), std::reverse_iterator<_Iter>(__first_));
   }
 
@@ -621,7 +622,7 @@ template <
     class _Type = typename iterator_traits<_Iter1>::value_type,
     class = __enable_if_t<is_trivially_move_constructible<_Type>::value && is_trivially_move_assignable<_Type>::value &&
                           __allocator_has_trivial_move_construct<_Alloc, _Type>::value> >
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter1
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 _Iter2
 __uninitialized_allocator_move_if_noexcept(_Alloc&, _Iter1 __first1, _Iter1 __last1, _Iter2 __first2) {
   if (__libcpp_is_constant_evaluated()) {
     while (__first1 != __last1) {

diff  --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index f781674662175..4d40732a75cf0 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -62,107 +62,107 @@ public:
     typedef typename add_lvalue_reference<allocator_type>::type __alloc_ref;
     typedef typename add_lvalue_reference<allocator_type>::type __alloc_const_ref;
 
-    _LIBCPP_INLINE_VISIBILITY __alloc_rr&           __alloc() _NOEXCEPT         {return __end_cap_.second();}
-    _LIBCPP_INLINE_VISIBILITY const __alloc_rr&     __alloc() const _NOEXCEPT   {return __end_cap_.second();}
-    _LIBCPP_INLINE_VISIBILITY pointer&              __end_cap() _NOEXCEPT       {return __end_cap_.first();}
-    _LIBCPP_INLINE_VISIBILITY const pointer&        __end_cap() const _NOEXCEPT {return __end_cap_.first();}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY __alloc_rr&           __alloc() _NOEXCEPT         {return __end_cap_.second();}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const __alloc_rr&     __alloc() const _NOEXCEPT   {return __end_cap_.second();}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY pointer&              __end_cap() _NOEXCEPT       {return __end_cap_.first();}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const pointer&        __end_cap() const _NOEXCEPT {return __end_cap_.first();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     __split_buffer()
         _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     explicit __split_buffer(__alloc_rr& __a);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     explicit __split_buffer(const __alloc_rr& __a);
-    __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
-    ~__split_buffer();
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__split_buffer();
 
-    __split_buffer(__split_buffer&& __c)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c)
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
-    __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
-    __split_buffer& operator=(__split_buffer&& __c)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer(__split_buffer&& __c, const __alloc_rr& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __split_buffer& operator=(__split_buffer&& __c)
         _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
                 is_nothrow_move_assignable<allocator_type>::value) ||
                !__alloc_traits::propagate_on_container_move_assignment::value);
 
-    _LIBCPP_INLINE_VISIBILITY       iterator begin() _NOEXCEPT       {return __begin_;}
-    _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
-    _LIBCPP_INLINE_VISIBILITY       iterator end() _NOEXCEPT         {return __end_;}
-    _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT   {return __end_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY       iterator begin() _NOEXCEPT       {return __begin_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT {return __begin_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY       iterator end() _NOEXCEPT         {return __end_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT   {return __end_;}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void clear() _NOEXCEPT
         {__destruct_at_end(__begin_);}
-    _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
-    _LIBCPP_INLINE_VISIBILITY bool empty()     const {return __end_ == __begin_;}
-    _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
-    _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
-    _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
-
-    _LIBCPP_INLINE_VISIBILITY       reference front()       {return *__begin_;}
-    _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
-    _LIBCPP_INLINE_VISIBILITY       reference back()        {return *(__end_ - 1);}
-    _LIBCPP_INLINE_VISIBILITY const_reference back() const  {return *(__end_ - 1);}
-
-    void reserve(size_type __n);
-    void shrink_to_fit() _NOEXCEPT;
-    void push_front(const_reference __x);
-    _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
-    void push_front(value_type&& __x);
-    void push_back(value_type&& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type size() const {return static_cast<size_type>(__end_ - __begin_);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY bool empty()     const {return __end_ == __begin_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type capacity() const {return static_cast<size_type>(__end_cap() - __first_);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __front_spare() const {return static_cast<size_type>(__begin_ - __first_);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __back_spare() const {return static_cast<size_type>(__end_cap() - __end_);}
+
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY       reference front()       {return *__begin_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const {return *__begin_;}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY       reference back()        {return *(__end_ - 1);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back() const  {return *(__end_ - 1);}
+
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_front(value_type&& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(value_type&& __x);
     template <class... _Args>
-        void emplace_back(_Args&&... __args);
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 void emplace_back(_Args&&... __args);
 
-    _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
-    _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
 
-    void __construct_at_end(size_type __n);
-    void __construct_at_end(size_type __n, const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, const_reference __x);
     template <class _InputIter>
-    __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
         __construct_at_end(_InputIter __first, _InputIter __last);
     template <class _ForwardIterator>
-    __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
         __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
 
-    _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin)
         {__destruct_at_begin(__new_begin, is_trivially_destructible<value_type>());}
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_begin(pointer __new_begin, false_type);
-        _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_begin(pointer __new_begin, true_type);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __destruct_at_end(pointer __new_last) _NOEXCEPT
         {__destruct_at_end(__new_last, false_type());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_end(pointer __new_last, false_type) _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
         void __destruct_at_end(pointer __new_last, true_type) _NOEXCEPT;
 
-    void swap(__split_buffer& __x)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(__split_buffer& __x)
         _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
                    __is_nothrow_swappable<__alloc_rr>::value);
 
-    bool __invariants() const;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
 
 private:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __move_assign_alloc(__split_buffer& __c, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
         {
             __alloc() = _VSTD::move(__c.__alloc());
         }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __move_assign_alloc(__split_buffer&, false_type) _NOEXCEPT
         {}
 
     struct _ConstructTransaction {
-      explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
+      _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit _ConstructTransaction(pointer* __p, size_type __n) _NOEXCEPT
       : __pos_(*__p), __end_(*__p + __n), __dest_(__p) {
       }
-      ~_ConstructTransaction() {
+      _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
         *__dest_ = __pos_;
       }
       pointer __pos_;
@@ -173,6 +173,7 @@ private:
 };
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 __split_buffer<_Tp, _Allocator>::__invariants() const
 {
@@ -203,6 +204,7 @@ __split_buffer<_Tp, _Allocator>::__invariants() const
 //  Precondition:  size() + __n <= capacity()
 //  Postcondition:  size() == size() + __n
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
 {
@@ -219,6 +221,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n)
 //  Postcondition:  size() == old size() + __n
 //  Postcondition:  [i] == __x for all i in [size() - __n, __n)
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
 {
@@ -231,7 +234,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(size_type __n, const_referen
 
 template <class _Tp, class _Allocator>
 template <class _InputIter>
-__enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_exactly_cpp17_input_iterator<_InputIter>::value>
 __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIter __last)
 {
     __alloc_rr& __a = this->__alloc();
@@ -254,7 +257,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_InputIter __first, _InputIt
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
-__enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
+_LIBCPP_CONSTEXPR_AFTER_CXX17 __enable_if_t<__is_cpp17_forward_iterator<_ForwardIterator>::value>
 __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last)
 {
     _ConstructTransaction __tx(&this->__end_, _VSTD::distance(__first, __last));
@@ -265,6 +268,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type)
@@ -274,6 +278,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type)
@@ -282,6 +287,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT
@@ -291,6 +297,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT
@@ -299,6 +306,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __start, __alloc_rr& __a)
     : __end_cap_(nullptr, __a)
 {
@@ -314,6 +322,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 __split_buffer<_Tp, _Allocator>::__split_buffer()
     _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
@@ -322,6 +331,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer()
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
     : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -329,6 +339,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
     : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a)
@@ -336,6 +347,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __split_buffer<_Tp, _Allocator>::~__split_buffer()
 {
     clear();
@@ -344,6 +356,7 @@ __split_buffer<_Tp, _Allocator>::~__split_buffer()
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
     _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value)
     : __first_(_VSTD::move(__c.__first_)),
@@ -358,6 +371,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __alloc_rr& __a)
     : __end_cap_(nullptr, __a)
 {
@@ -384,6 +398,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(__split_buffer&& __c, const __al
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 __split_buffer<_Tp, _Allocator>&
 __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
     _NOEXCEPT_((__alloc_traits::propagate_on_container_move_assignment::value &&
@@ -404,6 +419,7 @@ __split_buffer<_Tp, _Allocator>::operator=(__split_buffer&& __c)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
         _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value||
@@ -417,6 +433,7 @@ __split_buffer<_Tp, _Allocator>::swap(__split_buffer& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
 {
@@ -433,6 +450,7 @@ __split_buffer<_Tp, _Allocator>::reserve(size_type __n)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 {
@@ -460,6 +478,7 @@ __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
 {
@@ -489,6 +508,7 @@ __split_buffer<_Tp, _Allocator>::push_front(const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
 {
@@ -519,6 +539,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
@@ -549,6 +570,7 @@ __split_buffer<_Tp, _Allocator>::push_back(const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
 {
@@ -580,6 +602,7 @@ __split_buffer<_Tp, _Allocator>::push_back(value_type&& __x)
 
 template <class _Tp, class _Allocator>
 template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 {
@@ -610,6 +633,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y)

diff  --git a/libcxx/include/memory b/libcxx/include/memory
index 56f8159fbd445..a986d76c8b4ef 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -838,6 +838,8 @@ template<size_t N, class T>
 
 */
 
+#include <__algorithm/copy.h>
+#include <__algorithm/move.h>
 #include <__assert> // all public C++ headers provide the assertion handler
 #include <__config>
 #include <__memory/addressof.h>
@@ -941,21 +943,31 @@ template <class _Tp, class _Alloc>
 struct __temp_value {
     typedef allocator_traits<_Alloc> _Traits;
 
+#ifdef _LIBCPP_CXX03_LANG
     typename aligned_storage<sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)>::type __v;
+#else
+    union { _Tp __v; };
+#endif
     _Alloc &__a;
 
-    _Tp *__addr() { return reinterpret_cast<_Tp *>(addressof(__v)); }
-    _Tp &   get() { return *__addr(); }
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp *__addr() {
+#ifdef _LIBCPP_CXX03_LANG
+        return reinterpret_cast<_Tp*>(std::addressof(__v));
+#else
+        return std::addressof(__v);
+#endif
+    }
+
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _Tp &   get() { return *__addr(); }
 
     template<class... _Args>
     _LIBCPP_NO_CFI
-    __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
-      _Traits::construct(__a, reinterpret_cast<_Tp*>(addressof(__v)),
-                         _VSTD::forward<_Args>(__args)...);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 __temp_value(_Alloc &__alloc, _Args&& ... __args) : __a(__alloc) {
+      _Traits::construct(__a, __addr(), std::forward<_Args>(__args)...);
     }
 
-    ~__temp_value() { _Traits::destroy(__a, __addr()); }
-    };
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 ~__temp_value() { _Traits::destroy(__a, __addr()); }
+};
 
 template<typename _Alloc, typename = void, typename = void>
 struct __is_allocator : false_type {};

diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 30030f85e43c3..252a0f051ff54 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -360,12 +360,12 @@ public:
     static_assert((is_same<typename allocator_type::value_type, value_type>::value),
                   "Allocator::value_type must be same type as value_type");
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
     {
         _VSTD::__debug_db_insert_c(this);
     }
-    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
 #if _LIBCPP_STD_VER <= 14
         _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
 #else
@@ -375,13 +375,14 @@ public:
     {
         _VSTD::__debug_db_insert_c(this);
     }
-    explicit vector(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
 #if _LIBCPP_STD_VER > 11
-    explicit vector(size_type __n, const allocator_type& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
 #endif
-    vector(size_type __n, const value_type& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __x);
 
     template <class = __enable_if_t<__is_allocator<_Allocator>::value> >
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
     vector(size_type __n, const value_type& __x, const allocator_type& __a)
         : __end_cap_(nullptr, __a)
     {
@@ -394,6 +395,7 @@ public:
     }
 
     template <class _InputIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         vector(_InputIterator __first,
                typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
                                  is_constructible<
@@ -401,12 +403,14 @@ public:
                                     typename iterator_traits<_InputIterator>::reference>::value,
                                  _InputIterator>::type __last);
     template <class _InputIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
                typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
                                  is_constructible<
                                     value_type,
                                     typename iterator_traits<_InputIterator>::reference>::value>::type* = 0);
     template <class _ForwardIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         vector(_ForwardIterator __first,
                typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
                                  is_constructible<
@@ -414,13 +418,14 @@ public:
                                     typename iterator_traits<_ForwardIterator>::reference>::value,
                                  _ForwardIterator>::type __last);
     template <class _ForwardIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
                typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
                                  is_constructible<
                                     value_type,
                                     typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     ~vector()
     {
       __annotate_delete();
@@ -433,24 +438,24 @@ public:
       }
     }
 
-    vector(const vector& __x);
-    vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __x, const __type_identity_t<allocator_type>& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector& operator=(const vector& __x);
 
 #ifndef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector(initializer_list<value_type> __il);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector(initializer_list<value_type> __il, const allocator_type& __a);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector& operator=(initializer_list<value_type> __il)
         {assign(__il.begin(), __il.end()); return *this;}
 #endif // !_LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __x)
 #if _LIBCPP_STD_VER > 14
         noexcept;
@@ -458,14 +463,14 @@ public:
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector(vector&& __x, const __type_identity_t<allocator_type>& __a);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     vector& operator=(vector&& __x)
         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 
     template <class _InputIterator>
-        typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
             is_constructible<
                  value_type,
                  typename iterator_traits<_InputIterator>::reference>::value,
@@ -473,6 +478,7 @@ public:
         >::type
         assign(_InputIterator __first, _InputIterator __last);
     template <class _ForwardIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -483,119 +489,120 @@ public:
         >::type
         assign(_ForwardIterator __first, _ForwardIterator __last);
 
-    void assign(size_type __n, const_reference __u);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const_reference __u);
 
 #ifndef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void assign(initializer_list<value_type> __il)
         {assign(__il.begin(), __il.end());}
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     allocator_type get_allocator() const _NOEXCEPT
         {return this->__alloc();}
 
-    _LIBCPP_INLINE_VISIBILITY iterator               begin() _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY const_iterator         begin()   const _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY iterator               end() _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY const_iterator         end()     const _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator               begin() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator         begin()   const _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator               end() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_iterator         end()     const _NOEXCEPT;
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     reverse_iterator       rbegin() _NOEXCEPT
         {return       reverse_iterator(end());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator rbegin()  const _NOEXCEPT
         {return const_reverse_iterator(end());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     reverse_iterator       rend() _NOEXCEPT
         {return       reverse_iterator(begin());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator rend()    const _NOEXCEPT
         {return const_reverse_iterator(begin());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_iterator         cbegin()  const _NOEXCEPT
         {return begin();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_iterator         cend()    const _NOEXCEPT
         {return end();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crbegin() const _NOEXCEPT
         {return rbegin();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_reverse_iterator crend()   const _NOEXCEPT
         {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     size_type size() const _NOEXCEPT
         {return static_cast<size_type>(this->__end_ - this->__begin_);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     size_type capacity() const _NOEXCEPT
         {return static_cast<size_type>(__end_cap() - this->__begin_);}
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     bool empty() const _NOEXCEPT
         {return this->__begin_ == this->__end_;}
-    size_type max_size() const _NOEXCEPT;
-    void reserve(size_type __n);
-    void shrink_to_fit() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
 
-    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n) _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
-    reference       at(size_type __n);
-    const_reference at(size_type __n) const;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n) _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 reference       at(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference at(size_type __n) const;
 
-    _LIBCPP_INLINE_VISIBILITY reference       front() _NOEXCEPT
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference       front() _NOEXCEPT
     {
         _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
         return *this->__begin_;
     }
-    _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference front() const _NOEXCEPT
     {
         _LIBCPP_ASSERT(!empty(), "front() called on an empty vector");
         return *this->__begin_;
     }
-    _LIBCPP_INLINE_VISIBILITY reference       back() _NOEXCEPT
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY reference       back() _NOEXCEPT
     {
         _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
         return *(this->__end_ - 1);
     }
-    _LIBCPP_INLINE_VISIBILITY const_reference back()  const _NOEXCEPT
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY const_reference back()  const _NOEXCEPT
     {
         _LIBCPP_ASSERT(!empty(), "back() called on an empty vector");
         return *(this->__end_ - 1);
     }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     value_type*       data() _NOEXCEPT
         {return _VSTD::__to_address(this->__begin_);}
-    _LIBCPP_INLINE_VISIBILITY
+
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const value_type* data() const _NOEXCEPT
         {return _VSTD::__to_address(this->__begin_);}
 
-    _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(const_reference __x);
 
-    _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x);
 
     template <class... _Args>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
 #if _LIBCPP_STD_VER > 14
         reference emplace_back(_Args&&... __args);
 #else
         void      emplace_back(_Args&&... __args);
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void pop_back();
 
-    iterator insert(const_iterator __position, const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const_reference __x);
 
-    iterator insert(const_iterator __position, value_type&& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, value_type&& __x);
     template <class... _Args>
-    iterator emplace(const_iterator __position, _Args&&... __args);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args);
 
-    iterator insert(const_iterator __position, size_type __n, const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const_reference __x);
     template <class _InputIterator>
-        typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
             is_constructible<
                  value_type,
                  typename iterator_traits<_InputIterator>::reference>::value,
@@ -603,6 +610,7 @@ public:
         >::type
         insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
     template <class _ForwardIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -614,15 +622,15 @@ public:
         insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
 
 #ifndef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     iterator insert(const_iterator __position, initializer_list<value_type> __il)
         {return insert(__position, __il.begin(), __il.end());}
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
-    iterator erase(const_iterator __first, const_iterator __last);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void clear() _NOEXCEPT
     {
         size_type __old_size = size();
@@ -631,10 +639,10 @@ public:
         std::__debug_db_invalidate_all(this);
     }
 
-    void resize(size_type __sz);
-    void resize(size_type __sz, const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, const_reference __x);
 
-    void swap(vector&)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
 #if _LIBCPP_STD_VER >= 14
         _NOEXCEPT;
 #else
@@ -642,7 +650,7 @@ public:
                     __is_nothrow_swappable<allocator_type>::value);
 #endif
 
-    bool __invariants() const;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
 
 #ifdef _LIBCPP_ENABLE_DEBUG_MODE
 
@@ -661,7 +669,6 @@ private:
 
     _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
 
-
     //  Allocate space for __n objects
     //  throws length_error if __n > max_size()
     //  throws (probably bad_alloc) if memory run out
@@ -669,7 +676,7 @@ private:
     //  Precondition:  __n > 0
     //  Postcondition:  capacity() >= __n
     //  Postcondition:  size() == 0
-    _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
         if (__n > max_size())
             __throw_length_error();
         auto __allocation = std::__allocate_at_least(__alloc(), __n);
@@ -679,46 +686,48 @@ private:
         __annotate_new(0);
     }
 
-    void __vdeallocate() _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
-    void __construct_at_end(size_type __n);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __construct_at_end(size_type __n, const_reference __x);
     template <class _ForwardIterator>
+        _LIBCPP_CONSTEXPR_AFTER_CXX17
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value,
             void
         >::type
         __construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n);
-    void __append(size_type __n);
-    void __append(size_type __n, const_reference __x);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     iterator       __make_iter(pointer __p) _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     const_iterator __make_iter(const_pointer __p) const _NOEXCEPT;
-    void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
-    pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
-    void __move_range(pointer __from_s, pointer __from_e, pointer __to);
-    void __move_assign(vector& __c, true_type)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 pointer __swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_range(pointer __from_s, pointer __from_e, pointer __to);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
-    void __move_assign(vector& __c, false_type)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type)
         _NOEXCEPT_(__alloc_traits::is_always_equal::value);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __destruct_at_end(pointer __new_last) _NOEXCEPT
     {
-        __invalidate_iterators_past(__new_last);
+        if (!__libcpp_is_constant_evaluated())
+            __invalidate_iterators_past(__new_last);
         size_type __old_size = size();
         __base_destruct_at_end(__new_last);
         __annotate_shrink(__old_size);
     }
 
     template <class _Up>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     inline void __push_back_slow_path(_Up&& __x);
 
     template <class... _Args>
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     inline void __emplace_back_slow_path(_Args&&... __args);
 
     // The following functions are no-ops outside of AddressSanitizer mode.
@@ -726,39 +735,40 @@ private:
     // may not meet the AddressSanitizer alignment constraints.
     // See the documentation for __sanitizer_annotate_contiguous_container for more details.
 #ifndef _LIBCPP_HAS_NO_ASAN
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __annotate_contiguous_container(const void *__beg, const void *__end,
                                          const void *__old_mid,
                                          const void *__new_mid) const
     {
 
-      if (__beg && is_same<allocator_type, __default_allocator_type>::value)
+      if (!__libcpp_is_constant_evaluated() && __beg && is_same<allocator_type, __default_allocator_type>::value)
         __sanitizer_annotate_contiguous_container(__beg, __end, __old_mid, __new_mid);
     }
 #else
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __annotate_contiguous_container(const void*, const void*, const void*,
                                          const void*) const _NOEXCEPT {}
 #endif
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __annotate_new(size_type __current_size) const _NOEXCEPT {
       __annotate_contiguous_container(data(), data() + capacity(),
                                       data() + capacity(), data() + __current_size);
     }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __annotate_delete() const _NOEXCEPT {
       __annotate_contiguous_container(data(), data() + capacity(),
                                       data() + size(), data() + capacity());
     }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __annotate_increase(size_type __n) const _NOEXCEPT
     {
       __annotate_contiguous_container(data(), data() + capacity(),
                                       data() + size(), data() + size() + __n);
     }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
     void __annotate_shrink(size_type __old_size) const _NOEXCEPT
     {
       __annotate_contiguous_container(data(), data() + capacity(),
@@ -766,13 +776,14 @@ private:
     }
 
   struct _ConstructTransaction {
+    _LIBCPP_CONSTEXPR_AFTER_CXX17
     explicit _ConstructTransaction(vector &__v, size_type __n)
       : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) {
 #ifndef _LIBCPP_HAS_NO_ASAN
       __v_.__annotate_increase(__n);
 #endif
     }
-    ~_ConstructTransaction() {
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 ~_ConstructTransaction() {
       __v_.__end_ = __pos_;
 #ifndef _LIBCPP_HAS_NO_ASAN
       if (__pos_ != __new_end_) {
@@ -791,7 +802,7 @@ private:
   };
 
   template <class ..._Args>
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __construct_one_at_end(_Args&& ...__args) {
     _ConstructTransaction __tx(*this, 1);
     __alloc_traits::construct(this->__alloc(), _VSTD::__to_address(__tx.__pos_),
@@ -799,23 +810,23 @@ private:
     ++__tx.__pos_;
   }
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   allocator_type& __alloc() _NOEXCEPT
       {return this->__end_cap_.second();}
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   const allocator_type& __alloc() const _NOEXCEPT
       {return this->__end_cap_.second();}
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   pointer& __end_cap() _NOEXCEPT
       {return this->__end_cap_.first();}
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   const pointer& __end_cap() const _NOEXCEPT
       {return this->__end_cap_.first();}
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __clear() _NOEXCEPT {__base_destruct_at_end(this->__begin_);}
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __base_destruct_at_end(pointer __new_last) _NOEXCEPT {
     pointer __soon_to_be_end = this->__end_;
     while (__new_last != __soon_to_be_end)
@@ -823,12 +834,12 @@ private:
     this->__end_ = __new_last;
   }
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __copy_assign_alloc(const vector& __c)
       {__copy_assign_alloc(__c, integral_constant<bool,
                     __alloc_traits::propagate_on_container_copy_assignment::value>());}
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __move_assign_alloc(vector& __c)
       _NOEXCEPT_(
           !__alloc_traits::propagate_on_container_move_assignment::value ||
@@ -846,7 +857,7 @@ private:
       _VSTD::__throw_out_of_range("vector");
   }
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __copy_assign_alloc(const vector& __c, true_type)
   {
     if (__alloc() != __c.__alloc())
@@ -858,18 +869,18 @@ private:
     __alloc() = __c.__alloc();
   }
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __copy_assign_alloc(const vector&, false_type)
   {}
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __move_assign_alloc(vector& __c, true_type)
       _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
   {
     __alloc() = _VSTD::move(__c.__alloc());
   }
 
-  _LIBCPP_INLINE_VISIBILITY
+  _LIBCPP_CONSTEXPR_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
   void __move_assign_alloc(vector&, false_type)
       _NOEXCEPT
   {}
@@ -894,6 +905,7 @@ vector(_InputIterator, _InputIterator, _Alloc)
 #endif
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v)
 {
@@ -911,6 +923,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::pointer
 vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type&>& __v, pointer __p)
 {
@@ -931,6 +944,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
 {
@@ -943,6 +957,7 @@ vector<_Tp, _Allocator>::__vdeallocate() _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::size_type
 vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
 {
@@ -952,6 +967,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT
 
 //  Precondition:  __new_size > capacity()
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::size_type
 vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
@@ -971,6 +987,7 @@ vector<_Tp, _Allocator>::__recommend(size_type __new_size) const
 //  Precondition:  size() + __n <= capacity()
 //  Postcondition:  size() == size() + __n
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
 {
@@ -988,6 +1005,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n)
 //  Postcondition:  size() == old size() + __n
 //  Postcondition:  [i] == __x for all i in [size() - __n, __n)
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 void
 vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
@@ -1001,6 +1019,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x)
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -1017,6 +1036,7 @@ vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIt
 //  Postcondition:  size() == size() + __n
 //  Exception safety: strong.
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__append(size_type __n)
 {
@@ -1036,6 +1056,7 @@ vector<_Tp, _Allocator>::__append(size_type __n)
 //  Postcondition:  size() == size() + __n
 //  Exception safety: strong.
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
 {
@@ -1051,6 +1072,7 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(size_type __n)
 {
     _VSTD::__debug_db_insert_c(this);
@@ -1063,6 +1085,7 @@ vector<_Tp, _Allocator>::vector(size_type __n)
 
 #if _LIBCPP_STD_VER > 11
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
     : __end_cap_(nullptr, __a)
 {
@@ -1076,6 +1099,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a)
 #endif
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
 {
     _VSTD::__debug_db_insert_c(this);
@@ -1088,6 +1112,7 @@ vector<_Tp, _Allocator>::vector(size_type __n, const value_type& __x)
 
 template <class _Tp, class _Allocator>
 template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(_InputIterator __first,
        typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
                          is_constructible<
@@ -1102,6 +1127,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first,
 
 template <class _Tp, class _Allocator>
 template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
        typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
                          is_constructible<
@@ -1116,6 +1142,7 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
                                 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
                                 is_constructible<
@@ -1134,6 +1161,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first,
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
                                 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value &&
                                 is_constructible<
@@ -1151,6 +1179,7 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(const vector& __x)
     : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc()))
 {
@@ -1164,6 +1193,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
     : __end_cap_(nullptr, __a)
 {
@@ -1177,6 +1207,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const __type_identity_t<alloc
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(vector&& __x)
 #if _LIBCPP_STD_VER > 14
@@ -1195,6 +1226,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_type>& __a)
     : __end_cap_(nullptr, __a)
@@ -1218,6 +1250,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const __type_identity_t<allocator_
 #ifndef _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
 {
@@ -1230,6 +1263,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
     : __end_cap_(nullptr, __a)
@@ -1245,6 +1279,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat
 #endif // _LIBCPP_CXX03_LANG
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>&
 vector<_Tp, _Allocator>::operator=(vector&& __x)
@@ -1256,6 +1291,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
     _NOEXCEPT_(__alloc_traits::is_always_equal::value)
@@ -1270,6 +1306,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
     _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
@@ -1284,6 +1321,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 vector<_Tp, _Allocator>&
 vector<_Tp, _Allocator>::operator=(const vector& __x)
@@ -1298,7 +1336,7 @@ vector<_Tp, _Allocator>::operator=(const vector& __x)
 
 template <class _Tp, class _Allocator>
 template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
     is_constructible<
        _Tp,
        typename iterator_traits<_InputIterator>::reference>::value,
@@ -1313,6 +1351,7 @@ vector<_Tp, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1350,6 +1389,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
 {
@@ -1372,6 +1412,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::begin() _NOEXCEPT
@@ -1380,6 +1421,7 @@ vector<_Tp, _Allocator>::begin() _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::const_iterator
 vector<_Tp, _Allocator>::begin() const _NOEXCEPT
@@ -1388,6 +1430,7 @@ vector<_Tp, _Allocator>::begin() const _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::end() _NOEXCEPT
@@ -1396,6 +1439,7 @@ vector<_Tp, _Allocator>::end() _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::const_iterator
 vector<_Tp, _Allocator>::end() const _NOEXCEPT
@@ -1404,6 +1448,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::reference
 vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
@@ -1413,6 +1458,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::const_reference
 vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
@@ -1422,6 +1468,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) const _NOEXCEPT
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::reference
 vector<_Tp, _Allocator>::at(size_type __n)
 {
@@ -1431,6 +1478,7 @@ vector<_Tp, _Allocator>::at(size_type __n)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::const_reference
 vector<_Tp, _Allocator>::at(size_type __n) const
 {
@@ -1440,6 +1488,7 @@ vector<_Tp, _Allocator>::at(size_type __n) const
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::reserve(size_type __n)
 {
@@ -1454,6 +1503,7 @@ vector<_Tp, _Allocator>::reserve(size_type __n)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 {
@@ -1477,6 +1527,7 @@ vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
 
 template <class _Tp, class _Allocator>
 template <class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
 {
@@ -1489,6 +1540,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up&& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 vector<_Tp, _Allocator>::push_back(const_reference __x)
@@ -1502,6 +1554,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 vector<_Tp, _Allocator>::push_back(value_type&& __x)
@@ -1516,6 +1569,7 @@ vector<_Tp, _Allocator>::push_back(value_type&& __x)
 
 template <class _Tp, class _Allocator>
 template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
 {
@@ -1529,6 +1583,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args)
 
 template <class _Tp, class _Allocator>
 template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 #if _LIBCPP_STD_VER > 14
 typename vector<_Tp, _Allocator>::reference
@@ -1549,6 +1604,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline
 void
 vector<_Tp, _Allocator>::pop_back()
@@ -1558,6 +1614,7 @@ vector<_Tp, _Allocator>::pop_back()
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::erase(const_iterator __position)
@@ -1569,12 +1626,14 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
     
diff erence_type __ps = __position - cbegin();
     pointer __p = this->__begin_ + __ps;
     this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
-    this->__invalidate_iterators_past(__p-1);
+    if (!__libcpp_is_constant_evaluated())
+        this->__invalidate_iterators_past(__p - 1);
     iterator __r = iterator(this, __p);
     return __r;
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
 {
@@ -1587,13 +1646,15 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
     pointer __p = this->__begin_ + (__first - begin());
     if (__first != __last) {
         this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
-        this->__invalidate_iterators_past(__p - 1);
+        if (!__libcpp_is_constant_evaluated())
+            this->__invalidate_iterators_past(__p - 1);
     }
     iterator __r = iterator(this, __p);
     return __r;
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointer __to)
 {
@@ -1613,13 +1674,15 @@ vector<_Tp, _Allocator>::__move_range(pointer __from_s, pointer __from_e, pointe
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
 {
     _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(_VSTD::addressof(__position)) == this,
                          "vector::insert(iterator, x) called with an iterator not referring to this vector");
     pointer __p = this->__begin_ + (__position - begin());
-    if (this->__end_ < this->__end_cap())
+    // We can't compare unrelated pointers inside constant expressions
+    if (!__libcpp_is_constant_evaluated() && this->__end_ < this->__end_cap())
     {
         if (__p == this->__end_)
         {
@@ -1645,6 +1708,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
 {
@@ -1675,6 +1739,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x)
 
 template <class _Tp, class _Allocator>
 template <class... _Args>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
 {
@@ -1705,6 +1770,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<_Tp, _Allocator>::iterator
 vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_reference __x)
 {
@@ -1713,7 +1779,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
     pointer __p = this->__begin_ + (__position - begin());
     if (__n > 0)
     {
-        if (__n <= static_cast<size_type>(this->__end_cap() - this->__end_))
+        // We can't compare unrelated pointers inside constant expressions
+        if (!__libcpp_is_constant_evaluated() && __n <= static_cast<size_type>(this->__end_cap() - this->__end_))
         {
             size_type __old_n = __n;
             pointer __old_last = this->__end_;
@@ -1745,7 +1812,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
 
 template <class _Tp, class _Allocator>
 template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value &&
     is_constructible<
        _Tp,
        typename iterator_traits<_InputIterator>::reference>::value,
@@ -1793,6 +1860,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs
 
 template <class _Tp, class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value &&
@@ -1841,6 +1909,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _ForwardIterator __fi
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::resize(size_type __sz)
 {
@@ -1852,6 +1921,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
 {
@@ -1863,6 +1933,7 @@ vector<_Tp, _Allocator>::resize(size_type __sz, const_reference __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<_Tp, _Allocator>::swap(vector& __x)
 #if _LIBCPP_STD_VER >= 14
@@ -1885,6 +1956,7 @@ vector<_Tp, _Allocator>::swap(vector& __x)
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 bool
 vector<_Tp, _Allocator>::__invariants() const
 {
@@ -2007,81 +2079,81 @@ public:
     typedef __bit_const_reference<vector>            const_reference;
 #endif
 private:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     size_type& __cap() _NOEXCEPT
         {return __cap_alloc_.first();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const size_type& __cap() const _NOEXCEPT
         {return __cap_alloc_.first();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     __storage_allocator& __alloc() _NOEXCEPT
         {return __cap_alloc_.second();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const __storage_allocator& __alloc() const _NOEXCEPT
         {return __cap_alloc_.second();}
 
     static const unsigned __bits_per_word = static_cast<unsigned>(sizeof(__storage_type) * CHAR_BIT);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     static size_type __internal_cap_to_external(size_type __n) _NOEXCEPT
         {return __n * __bits_per_word;}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     static size_type __external_cap_to_internal(size_type __n) _NOEXCEPT
         {return (__n - 1) / __bits_per_word + 1;}
 
 public:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value);
 
-    _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(const allocator_type& __a)
 #if _LIBCPP_STD_VER <= 14
         _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value);
 #else
         _NOEXCEPT;
 #endif
-    ~vector();
-    explicit vector(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 ~vector();
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n);
 #if _LIBCPP_STD_VER > 11
-    explicit vector(size_type __n, const allocator_type& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit vector(size_type __n, const allocator_type& __a);
 #endif
-    vector(size_type __n, const value_type& __v);
-    vector(size_type __n, const value_type& __v, const allocator_type& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(size_type __n, const value_type& __v, const allocator_type& __a);
     template <class _InputIterator>
-        vector(_InputIterator __first, _InputIterator __last,
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last,
                typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
     template <class _InputIterator>
-        vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
                typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type* = 0);
     template <class _ForwardIterator>
-        vector(_ForwardIterator __first, _ForwardIterator __last,
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last,
                typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
     template <class _ForwardIterator>
-        vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
                typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type* = 0);
 
-    vector(const vector& __v);
-    vector(const vector& __v, const allocator_type& __a);
-    vector& operator=(const vector& __v);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(const vector& __v, const allocator_type& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector& operator=(const vector& __v);
 
 #ifndef _LIBCPP_CXX03_LANG
-    vector(initializer_list<value_type> __il);
-    vector(initializer_list<value_type> __il, const allocator_type& __a);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(initializer_list<value_type> __il, const allocator_type& __a);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     vector& operator=(initializer_list<value_type> __il)
         {assign(__il.begin(), __il.end()); return *this;}
 
 #endif // !_LIBCPP_CXX03_LANG
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     vector(vector&& __v)
 #if _LIBCPP_STD_VER > 14
         noexcept;
 #else
         _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value);
 #endif
-    vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 vector(vector&& __v, const __type_identity_t<allocator_type>& __a);
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     vector& operator=(vector&& __v)
         _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value));
 
@@ -2089,93 +2161,93 @@ public:
         typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
            void
         >::type
-        assign(_InputIterator __first, _InputIterator __last);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_InputIterator __first, _InputIterator __last);
     template <class _ForwardIterator>
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value,
            void
         >::type
-        assign(_ForwardIterator __first, _ForwardIterator __last);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 assign(_ForwardIterator __first, _ForwardIterator __last);
 
-    void assign(size_type __n, const value_type& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void assign(size_type __n, const value_type& __x);
 
 #ifndef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void assign(initializer_list<value_type> __il)
         {assign(__il.begin(), __il.end());}
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 allocator_type get_allocator() const _NOEXCEPT
         {return allocator_type(this->__alloc());}
 
-    size_type max_size() const _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 size_type max_size() const _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     size_type capacity() const _NOEXCEPT
         {return __internal_cap_to_external(__cap());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     size_type size() const _NOEXCEPT
         {return __size_;}
-    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     bool empty() const _NOEXCEPT
         {return __size_ == 0;}
-    void reserve(size_type __n);
-    void shrink_to_fit() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void reserve(size_type __n);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void shrink_to_fit() _NOEXCEPT;
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     iterator begin() _NOEXCEPT
         {return __make_iter(0);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_iterator begin() const _NOEXCEPT
         {return __make_iter(0);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     iterator end() _NOEXCEPT
         {return __make_iter(__size_);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_iterator end()   const _NOEXCEPT
         {return __make_iter(__size_);}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     reverse_iterator rbegin() _NOEXCEPT
         {return       reverse_iterator(end());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_reverse_iterator rbegin() const _NOEXCEPT
         {return const_reverse_iterator(end());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     reverse_iterator rend() _NOEXCEPT
         {return       reverse_iterator(begin());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_reverse_iterator rend()   const _NOEXCEPT
         {return const_reverse_iterator(begin());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_iterator         cbegin()  const _NOEXCEPT
         {return __make_iter(0);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_iterator         cend()    const _NOEXCEPT
         {return __make_iter(__size_);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_reverse_iterator crbegin() const _NOEXCEPT
         {return rbegin();}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_reverse_iterator crend()   const _NOEXCEPT
         {return rend();}
 
-    _LIBCPP_INLINE_VISIBILITY reference       operator[](size_type __n)       {return __make_ref(__n);}
-    _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const {return __make_ref(__n);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference       operator[](size_type __n)       {return __make_ref(__n);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference operator[](size_type __n) const {return __make_ref(__n);}
     reference       at(size_type __n);
     const_reference at(size_type __n) const;
 
-    _LIBCPP_INLINE_VISIBILITY reference       front()       {return __make_ref(0);}
-    _LIBCPP_INLINE_VISIBILITY const_reference front() const {return __make_ref(0);}
-    _LIBCPP_INLINE_VISIBILITY reference       back()        {return __make_ref(__size_ - 1);}
-    _LIBCPP_INLINE_VISIBILITY const_reference back()  const {return __make_ref(__size_ - 1);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference       front()       {return __make_ref(0);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference front() const {return __make_ref(0);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference       back()        {return __make_ref(__size_ - 1);}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 const_reference back()  const {return __make_ref(__size_ - 1);}
 
-    void push_back(const value_type& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void push_back(const value_type& __x);
 #if _LIBCPP_STD_VER > 11
     template <class... _Args>
 #if _LIBCPP_STD_VER > 14
-    _LIBCPP_INLINE_VISIBILITY reference emplace_back(_Args&&... __args)
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 reference emplace_back(_Args&&... __args)
 #else
     _LIBCPP_INLINE_VISIBILITY void      emplace_back(_Args&&... __args)
 #endif
@@ -2187,54 +2259,54 @@ public:
     }
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;}
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void pop_back() {--__size_;}
 
 #if _LIBCPP_STD_VER > 11
     template <class... _Args>
-   _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator __position, _Args&&... __args)
+   _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator emplace(const_iterator __position, _Args&&... __args)
         { return insert ( __position, value_type ( _VSTD::forward<_Args>(__args)... )); }
 #endif
 
-    iterator insert(const_iterator __position, const value_type& __x);
-    iterator insert(const_iterator __position, size_type __n, const value_type& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, const value_type& __x);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator insert(const_iterator __position, size_type __n, const value_type& __x);
     template <class _InputIterator>
         typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
             iterator
         >::type
-        insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _InputIterator __first, _InputIterator __last);
     template <class _ForwardIterator>
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value,
             iterator
         >::type
-        insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 insert(const_iterator __position, _ForwardIterator __first, _ForwardIterator __last);
 
 #ifndef _LIBCPP_CXX03_LANG
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     iterator insert(const_iterator __position, initializer_list<value_type> __il)
         {return insert(__position, __il.begin(), __il.end());}
 #endif
 
-    _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __position);
-    iterator erase(const_iterator __first, const_iterator __last);
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __position);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 iterator erase(const_iterator __first, const_iterator __last);
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void clear() _NOEXCEPT {__size_ = 0;}
 
-    void swap(vector&)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void swap(vector&)
 #if _LIBCPP_STD_VER >= 14
         _NOEXCEPT;
 #else
         _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
                     __is_nothrow_swappable<allocator_type>::value);
 #endif
-    static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 static void swap(reference __x, reference __y) _NOEXCEPT { _VSTD::swap(__x, __y); }
 
-    void resize(size_type __sz, value_type __x = false);
-    void flip() _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void resize(size_type __sz, value_type __x = false);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void flip() _NOEXCEPT;
 
-    bool __invariants() const;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 bool __invariants() const;
 
 private:
     _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
@@ -2254,52 +2326,56 @@ private:
     //  Precondition:  __n > 0
     //  Postcondition:  capacity() >= __n
     //  Postcondition:  size() == 0
-    _LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
+    _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vallocate(size_type __n) {
         if (__n > max_size())
             __throw_length_error();
         auto __allocation = std::__allocate_at_least(__alloc(), __external_cap_to_internal(__n));
         __begin_ = __allocation.ptr;
         __size_ = 0;
         __cap() = __allocation.count;
+        if (__libcpp_is_constant_evaluated()) {
+            for (size_type __i = 0; __i != __cap(); ++__i)
+                std::__construct_at(std::__to_address(__begin_) + __i);
+        }
     }
 
-    void __vdeallocate() _NOEXCEPT;
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __vdeallocate() _NOEXCEPT;
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     static size_type __align_it(size_type __new_size) _NOEXCEPT
         {return (__new_size + (__bits_per_word-1)) & ~((size_type)__bits_per_word-1);}
-    _LIBCPP_INLINE_VISIBILITY  size_type __recommend(size_type __new_size) const;
-    _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x);
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17  size_type __recommend(size_type __new_size) const;
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void __construct_at_end(size_type __n, bool __x);
     template <class _ForwardIterator>
         typename enable_if
         <
             __is_cpp17_forward_iterator<_ForwardIterator>::value,
             void
         >::type
-        __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
-    void __append(size_type __n, const_reference __x);
-    _LIBCPP_INLINE_VISIBILITY
+        _LIBCPP_CONSTEXPR_AFTER_CXX17 __construct_at_end(_ForwardIterator __first, _ForwardIterator __last);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __append(size_type __n, const_reference __x);
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     reference __make_ref(size_type __pos) _NOEXCEPT
         {return reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_reference __make_ref(size_type __pos) const _NOEXCEPT {
         return __bit_const_reference<vector>(__begin_ + __pos / __bits_per_word,
                                              __storage_type(1) << __pos % __bits_per_word);
     }
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     iterator __make_iter(size_type __pos) _NOEXCEPT
         {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     const_iterator __make_iter(size_type __pos) const _NOEXCEPT
         {return const_iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT
         {return begin() + (__p - cbegin());}
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __copy_assign_alloc(const vector& __v)
         {__copy_assign_alloc(__v, integral_constant<bool,
                       __storage_traits::propagate_on_container_copy_assignment::value>());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __copy_assign_alloc(const vector& __c, true_type)
         {
             if (__alloc() != __c.__alloc())
@@ -2307,33 +2383,33 @@ private:
             __alloc() = __c.__alloc();
         }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __copy_assign_alloc(const vector&, false_type)
         {}
 
-    void __move_assign(vector& __c, false_type);
-    void __move_assign(vector& __c, true_type)
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, false_type);
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 void __move_assign(vector& __c, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value);
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __move_assign_alloc(vector& __c)
         _NOEXCEPT_(
             !__storage_traits::propagate_on_container_move_assignment::value ||
             is_nothrow_move_assignable<allocator_type>::value)
         {__move_assign_alloc(__c, integral_constant<bool,
                       __storage_traits::propagate_on_container_move_assignment::value>());}
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __move_assign_alloc(vector& __c, true_type)
         _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
         {
             __alloc() = _VSTD::move(__c.__alloc());
         }
 
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     void __move_assign_alloc(vector&, false_type)
         _NOEXCEPT
         {}
 
-    size_t __hash_code() const _NOEXCEPT;
+    _LIBCPP_CONSTEXPR_AFTER_CXX17 size_t __hash_code() const _NOEXCEPT;
 
     friend class __bit_reference<vector>;
     friend class __bit_const_reference<vector>;
@@ -2344,7 +2420,7 @@ private:
 };
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
 {
     if (this->__begin_ != nullptr)
@@ -2357,6 +2433,7 @@ vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<bool, _Allocator>::size_type
 vector<bool, _Allocator>::max_size() const _NOEXCEPT
 {
@@ -2369,7 +2446,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT
 
 //  Precondition:  __new_size > capacity()
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<bool, _Allocator>::size_type
 vector<bool, _Allocator>::__recommend(size_type __new_size) const
 {
@@ -2387,7 +2464,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const
 //  Precondition:  size() + __n <= capacity()
 //  Postcondition:  size() == size() + __n
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 void
 vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
 {
@@ -2405,6 +2482,7 @@ vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x)
 
 template <class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2425,7 +2503,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI
 }
 
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector()
     _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value)
     : __begin_(nullptr),
@@ -2435,7 +2513,7 @@ vector<bool, _Allocator>::vector()
 }
 
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(const allocator_type& __a)
 #if _LIBCPP_STD_VER <= 14
         _NOEXCEPT_(is_nothrow_copy_constructible<allocator_type>::value)
@@ -2449,6 +2527,7 @@ vector<bool, _Allocator>::vector(const allocator_type& __a)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(size_type __n)
     : __begin_(nullptr),
       __size_(0),
@@ -2463,6 +2542,7 @@ vector<bool, _Allocator>::vector(size_type __n)
 
 #if _LIBCPP_STD_VER > 11
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
@@ -2477,6 +2557,7 @@ vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a)
 #endif
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
     : __begin_(nullptr),
       __size_(0),
@@ -2490,6 +2571,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
@@ -2504,6 +2586,7 @@ vector<bool, _Allocator>::vector(size_type __n, const value_type& __x, const all
 
 template <class _Allocator>
 template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
        typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
     : __begin_(nullptr),
@@ -2530,6 +2613,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
 
 template <class _Allocator>
 template <class _InputIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a,
        typename enable_if<__is_exactly_cpp17_input_iterator<_InputIterator>::value>::type*)
     : __begin_(nullptr),
@@ -2556,6 +2640,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
 
 template <class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last,
                                 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
     : __begin_(nullptr),
@@ -2572,6 +2657,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
 
 template <class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a,
                                 typename enable_if<__is_cpp17_forward_iterator<_ForwardIterator>::value>::type*)
     : __begin_(nullptr),
@@ -2589,6 +2675,7 @@ vector<bool, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __la
 #ifndef _LIBCPP_CXX03_LANG
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
     : __begin_(nullptr),
       __size_(0),
@@ -2603,6 +2690,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
@@ -2619,6 +2707,7 @@ vector<bool, _Allocator>::vector(initializer_list<value_type> __il, const alloca
 #endif // _LIBCPP_CXX03_LANG
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::~vector()
 {
     if (__begin_ != nullptr)
@@ -2627,6 +2716,7 @@ vector<bool, _Allocator>::~vector()
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(const vector& __v)
     : __begin_(nullptr),
       __size_(0),
@@ -2640,6 +2730,7 @@ vector<bool, _Allocator>::vector(const vector& __v)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
     : __begin_(nullptr),
       __size_(0),
@@ -2653,6 +2744,7 @@ vector<bool, _Allocator>::vector(const vector& __v, const allocator_type& __a)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>&
 vector<bool, _Allocator>::operator=(const vector& __v)
 {
@@ -2674,7 +2766,7 @@ vector<bool, _Allocator>::operator=(const vector& __v)
 }
 
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 vector<bool, _Allocator>::vector(vector&& __v)
 #if _LIBCPP_STD_VER > 14
     _NOEXCEPT
 #else
@@ -2689,6 +2781,7 @@ inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator_type>& __a)
     : __begin_(nullptr),
       __size_(0),
@@ -2710,7 +2803,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const __type_identity_t<allocator
 }
 
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 vector<bool, _Allocator>&
 vector<bool, _Allocator>::operator=(vector&& __v)
     _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value))
@@ -2721,7 +2814,7 @@ vector<bool, _Allocator>::operator=(vector&& __v)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
 {
     if (__alloc() != __c.__alloc())
@@ -2731,7 +2824,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, false_type)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
     _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value)
 {
@@ -2745,7 +2838,7 @@ vector<bool, _Allocator>::__move_assign(vector& __c, true_type)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
 {
     __size_ = 0;
@@ -2768,7 +2861,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
 
 template <class _Allocator>
 template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
    void
 >::type
 vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
@@ -2780,6 +2873,7 @@ vector<bool, _Allocator>::assign(_InputIterator __first, _InputIterator __last)
 
 template <class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2803,7 +2897,7 @@ vector<bool, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __la
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::reserve(size_type __n)
 {
     if (__n > capacity())
@@ -2819,7 +2913,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::shrink_to_fit() _NOEXCEPT
 {
     if (__external_cap_to_internal(size()) > __cap())
@@ -2857,7 +2951,7 @@ vector<bool, _Allocator>::at(size_type __n) const
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::push_back(const value_type& __x)
 {
     if (this->__size_ == this->capacity())
@@ -2867,7 +2961,7 @@ vector<bool, _Allocator>::push_back(const value_type& __x)
 }
 
 template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
 vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __x)
 {
     iterator __r;
@@ -2892,7 +2986,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, const value_type& __
 }
 
 template <class _Allocator>
-typename vector<bool, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename vector<bool, _Allocator>::iterator
 vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const value_type& __x)
 {
     iterator __r;
@@ -2919,7 +3013,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, size_type __n, const
 
 template <class _Allocator>
 template <class _InputIterator>
-typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
+_LIBCPP_CONSTEXPR_AFTER_CXX17 typename enable_if <__is_exactly_cpp17_input_iterator<_InputIterator>::value,
     typename vector<bool, _Allocator>::iterator
 >::type
 vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
@@ -2961,6 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _InputIterator __fir
 
 template <class _Allocator>
 template <class _ForwardIterator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename enable_if
 <
     __is_cpp17_forward_iterator<_ForwardIterator>::value,
@@ -2994,7 +3089,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f
 }
 
 template <class _Allocator>
-inline _LIBCPP_INLINE_VISIBILITY
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<bool, _Allocator>::iterator
 vector<bool, _Allocator>::erase(const_iterator __position)
 {
@@ -3005,6 +3100,7 @@ vector<bool, _Allocator>::erase(const_iterator __position)
 }
 
 template <class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 typename vector<bool, _Allocator>::iterator
 vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
 {
@@ -3016,7 +3112,7 @@ vector<bool, _Allocator>::erase(const_iterator __first, const_iterator __last)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::swap(vector& __x)
 #if _LIBCPP_STD_VER >= 14
     _NOEXCEPT
@@ -3033,7 +3129,7 @@ vector<bool, _Allocator>::swap(vector& __x)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
 {
     size_type __cs = size();
@@ -3062,7 +3158,7 @@ vector<bool, _Allocator>::resize(size_type __sz, value_type __x)
 }
 
 template <class _Allocator>
-void
+_LIBCPP_CONSTEXPR_AFTER_CXX17 void
 vector<bool, _Allocator>::flip() _NOEXCEPT
 {
     // do middle whole words
@@ -3081,7 +3177,7 @@ vector<bool, _Allocator>::flip() _NOEXCEPT
 }
 
 template <class _Allocator>
-bool
+_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
 vector<bool, _Allocator>::__invariants() const
 {
     if (this->__begin_ == nullptr)
@@ -3100,7 +3196,7 @@ vector<bool, _Allocator>::__invariants() const
 }
 
 template <class _Allocator>
-size_t
+_LIBCPP_CONSTEXPR_AFTER_CXX17 size_t
 vector<bool, _Allocator>::__hash_code() const _NOEXCEPT
 {
     size_t __h = 0;
@@ -3122,12 +3218,13 @@ template <class _Allocator>
 struct _LIBCPP_TEMPLATE_VIS hash<vector<bool, _Allocator> >
     : public __unary_function<vector<bool, _Allocator>, size_t>
 {
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     size_t operator()(const vector<bool, _Allocator>& __vec) const _NOEXCEPT
         {return __vec.__hash_code();}
 };
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3137,6 +3234,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3145,6 +3243,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3153,6 +3252,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3161,6 +3261,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3169,6 +3270,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 bool
 operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y)
@@ -3177,6 +3279,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __
 }
 
 template <class _Tp, class _Allocator>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY
 void
 swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
@@ -3187,6 +3290,7 @@ swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y)
 
 #if _LIBCPP_STD_VER > 17
 template <class _Tp, class _Allocator, class _Up>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
 erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
   auto __old_size = __c.size();
@@ -3195,6 +3299,7 @@ erase(vector<_Tp, _Allocator>& __c, const _Up& __v) {
 }
 
 template <class _Tp, class _Allocator, class _Predicate>
+_LIBCPP_CONSTEXPR_AFTER_CXX17
 inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type
 erase_if(vector<_Tp, _Allocator>& __c, _Predicate __pred) {
   auto __old_size = __c.size();

diff  --git a/libcxx/src/include/sso_allocator.h b/libcxx/src/include/sso_allocator.h
index 2baf599c5c242..6a682fc43f86f 100644
--- a/libcxx/src/include/sso_allocator.h
+++ b/libcxx/src/include/sso_allocator.h
@@ -41,6 +41,11 @@ class _LIBCPP_HIDDEN __sso_allocator
     typedef _Tp*              pointer;
     typedef _Tp               value_type;
 
+    template <class U>
+    struct rebind {
+        using other = __sso_allocator<U, _Np>;
+    };
+
     _LIBCPP_INLINE_VISIBILITY __sso_allocator() throw() : __allocated_(false) {}
     _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
     template <class _Up> _LIBCPP_INLINE_VISIBILITY __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()

diff  --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
index 64ed36c70b767..3fd051f790619 100644
--- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -12,6 +12,8 @@
 
 // map& operator=(const map& m);
 
+// XFAIL: libcpp-has-debug-mode
+
 #include <map>
 #include <algorithm>
 #include <cassert>

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
index c1233ea8f10c0..c4866ea4c9b45 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -16,7 +16,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5));
@@ -42,5 +42,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
index eff0cdc99a167..0f5ec9061f52d 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<bool> d;
@@ -39,5 +39,14 @@ int main(int, char**)
     assert(d[3] == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
index 19cc7898238a0..10271efc3f403 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
@@ -77,5 +77,14 @@ int main(int, char**)
         assert(l2.get_allocator() == lo.get_allocator());
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
index cb14329067e06..986453a189049 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v;
@@ -42,5 +42,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp
index 03b3b3d868d17..0f818029c1ff9 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/compare.pass.cpp
@@ -20,7 +20,7 @@
 
 #include "test_comparisons.h"
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
     typedef std::vector<bool> VB;
     {
         const VB v1, v2;
@@ -76,5 +76,14 @@ int main(int, char**) {
         assert( (std::vector<bool>() >= std::vector<bool>()));
     }
 
+    return true;
+}
+
+int main(int, char**) {
+    test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp
index 68b27479ba00b..c2cb7f0298ddb 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/const_reference.pass.cpp
@@ -13,7 +13,7 @@
 
 #include "test_macros.h"
 
-bool test() {
+TEST_CONSTEXPR_CXX20 bool test() {
   using CRefT = std::vector<bool>::const_reference;
 #if !defined(_LIBCPP_VERSION) || defined(_LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL)
   ASSERT_SAME_TYPE(CRefT, bool);
@@ -32,6 +32,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
index 3fd2bf8d195de..8f07524d070bb 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
@@ -24,8 +24,7 @@
 #include "min_allocator.h"
 
 template <class C>
-void
-test0()
+TEST_CONSTEXPR_CXX20 void test0()
 {
 #if TEST_STD_VER > 14
     LIBCPP_STATIC_ASSERT((noexcept(C{})), "" );
@@ -45,8 +44,7 @@ test0()
 }
 
 template <class C>
-void
-test1(const typename C::allocator_type& a)
+TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a)
 {
 #if TEST_STD_VER > 14
     LIBCPP_STATIC_ASSERT((noexcept(C{typename C::allocator_type{}})), "" );
@@ -59,7 +57,7 @@ test1(const typename C::allocator_type& a)
     assert(c.get_allocator() == a);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     test0<std::vector<bool> >();
@@ -76,5 +74,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
index 9d236e0892d31..2f520d5abbf3e 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
@@ -20,8 +20,7 @@
 #include "min_allocator.h"
 
 template <class C, class Iterator>
-void
-test(Iterator first, Iterator last)
+TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last)
 {
     C c(first, last);
     LIBCPP_ASSERT(c.__invariants());
@@ -30,7 +29,7 @@ test(Iterator first, Iterator last)
         assert(*i == *first);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
     bool* an = a + sizeof(a)/sizeof(a[0]);
@@ -47,5 +46,14 @@ int main(int, char**)
     test<std::vector<bool, min_allocator<bool>> >(a, an);
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
index 3e4a37c3c5684..57e1cb2e0b502 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
@@ -21,8 +21,7 @@
 #include "min_allocator.h"
 
 template <class C, class Iterator>
-void
-test(Iterator first, Iterator last, const typename C::allocator_type& a)
+TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last, const typename C::allocator_type& a)
 {
     C c(first, last, a);
     LIBCPP_ASSERT(c.__invariants());
@@ -31,7 +30,7 @@ test(Iterator first, Iterator last, const typename C::allocator_type& a)
         assert(*i == *first);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
     bool* an = a + sizeof(a)/sizeof(a[0]);
@@ -54,5 +53,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
index 2763df7e11d5c..bcc5a16859d36 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -19,9 +19,8 @@
 #include "test_allocator.h"
 
 template <class C>
-void
-test2(typename C::size_type n,
-      typename C::allocator_type const& a = typename C::allocator_type ())
+TEST_CONSTEXPR_CXX20 void test2(typename C::size_type n,
+                                typename C::allocator_type const& a = typename C::allocator_type ())
 {
 #if TEST_STD_VER >= 14
     C c(n, a);
@@ -37,8 +36,7 @@ test2(typename C::size_type n,
 }
 
 template <class C>
-void
-test1(typename C::size_type n)
+TEST_CONSTEXPR_CXX20 void test1(typename C::size_type n)
 {
     C c(n);
     LIBCPP_ASSERT(c.__invariants());
@@ -49,14 +47,13 @@ test1(typename C::size_type n)
 }
 
 template <class C>
-void
-test(typename C::size_type n)
+TEST_CONSTEXPR_CXX20 void test(typename C::size_type n)
 {
     test1<C> ( n );
     test2<C> ( n );
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test<std::vector<bool> >(50);
 #if TEST_STD_VER >= 11
@@ -64,5 +61,14 @@ int main(int, char**)
     test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
index 068989330a31f..629e8ba57ca85 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
@@ -18,8 +18,7 @@
 #include "min_allocator.h"
 
 template <class C>
-void
-test(typename C::size_type n, const typename C::value_type& x)
+TEST_CONSTEXPR_CXX20 void test(typename C::size_type n, const typename C::value_type& x)
 {
     C c(n, x);
     LIBCPP_ASSERT(c.__invariants());
@@ -28,12 +27,21 @@ test(typename C::size_type n, const typename C::value_type& x)
         assert(*i == x);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test<std::vector<bool> >(50, true);
 #if TEST_STD_VER >= 11
     test<std::vector<bool, min_allocator<bool>> >(50, true);
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
index e19f3c4a9d531..94a44ad282b71 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -18,9 +18,9 @@
 #include "min_allocator.h"
 
 template <class C>
-void
-test(typename C::size_type n, const typename C::value_type& x,
-     const typename C::allocator_type& a)
+TEST_CONSTEXPR_CXX20 void test(typename C::size_type n,
+                                    const typename C::value_type& x,
+                                    const typename C::allocator_type& a)
 {
     C c(n, x, a);
     LIBCPP_ASSERT(c.__invariants());
@@ -30,12 +30,21 @@ test(typename C::size_type n, const typename C::value_type& x,
         assert(*i == x);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test<std::vector<bool> >(50, true, std::allocator<bool>());
 #if TEST_STD_VER >= 11
     test<std::vector<bool, min_allocator<bool>> >(50, true, min_allocator<bool>());
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
index 618a37faf70af..bfd37e956dbdf 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
@@ -19,8 +19,7 @@
 #include "min_allocator.h"
 
 template <class C>
-void
-test(const C& x)
+TEST_CONSTEXPR_CXX20 void test(const C& x)
 {
     typename C::size_type s = x.size();
     C c(x);
@@ -29,7 +28,7 @@ test(const C& x)
     assert(c == x);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
@@ -62,5 +61,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
index 7970b2c7ed962..468bf5d866004 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
@@ -18,8 +18,7 @@
 #include "min_allocator.h"
 
 template <class C>
-void
-test(const C& x, const typename C::allocator_type& a)
+TEST_CONSTEXPR_CXX20 void test(const C& x, const typename C::allocator_type& a)
 {
     typename C::size_type s = x.size();
     C c(x, a);
@@ -28,7 +27,7 @@ test(const C& x, const typename C::allocator_type& a)
     assert(c == x);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
@@ -61,5 +60,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+  return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp
index 121395bedff12..134af5a7979a1 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         typedef std::vector<bool> C;
@@ -65,5 +65,14 @@ int main(int, char**)
         assert(c.back() == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
index 52fe733df5d70..fccf6e5fb962c 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         typedef std::vector<bool> C;
@@ -88,5 +88,14 @@ int main(int, char**)
         assert(c.back() == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
index e0c0243e13902..ec4d2f97045dd 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/empty.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     typedef std::vector<bool> C;
@@ -43,5 +43,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
index 1e456de3bee74..d89984a4a30ba 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/enabled_hash.pass.cpp
@@ -19,12 +19,19 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
+TEST_CONSTEXPR_CXX20 bool test() {
+  test_hash_enabled_for_type<std::vector<bool> >();
+  test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>();
+
+  return true;
+}
+
 int main(int, char**) {
   test_library_hash_specializations_available();
-  {
-    test_hash_enabled_for_type<std::vector<bool> >();
-    test_hash_enabled_for_type<std::vector<bool, min_allocator<bool>>>();
-  }
+  test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
index 53a3eac6550a9..42d1e76a9c770 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     bool a1[] = {1, 0, 1};
     {
@@ -64,5 +64,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
index c2c6e561e82b7..c19ce9987e1e1 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     bool a1[] = {1, 0, 1};
     {
@@ -84,5 +84,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp
index 406aebae53991..73cca82e79f11 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp
@@ -20,7 +20,7 @@
 
 #include "test_macros.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         for (unsigned i = 1; i < 256; ++i)
@@ -41,5 +41,14 @@ int main(int, char**)
         }
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp
index f518b4601eef3..a088cd8119abc 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/get_allocator.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_allocator.h"
 #include "test_macros.h"
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
     {
         std::allocator<bool> alloc;
         const std::vector<bool> vb(alloc);
@@ -30,5 +30,14 @@ int main(int, char**) {
         assert(vb.get_allocator() == alloc);
     }
 
+    return true;
+}
+
+int main(int, char**) {
+  test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
index 216c0a53096ef..9b13922240d57 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<bool> d = {true, false, false, true};
@@ -37,5 +37,14 @@ int main(int, char**)
     assert(d[3] == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
index 7e1411281c475..0d5dd8a79fc53 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
@@ -19,7 +19,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
@@ -40,5 +40,14 @@ int main(int, char**)
     assert(d[3] == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
index 3cbcc25b2077e..2462e05f20360 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<bool> d(10, true);
@@ -61,5 +61,14 @@ int main(int, char**)
     assert(d[13] == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
index 4ee9ea5d7f358..d4756cd0fee63 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -20,7 +20,7 @@
 #include "test_iterators.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -142,5 +142,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
index 84cafc90cc777..feea1888b70a3 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -87,5 +87,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
index 4cc48988fce75..b9a926eef5ec7 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -84,5 +84,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
index 1714c73742b62..9aaaac7a5557f 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
@@ -22,7 +22,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     using IterRefT = std::iterator_traits<std::vector<bool>::iterator>::reference;
     ASSERT_SAME_TYPE(IterRefT, std::vector<bool>::reference);
@@ -66,6 +66,8 @@ int main(int, char**)
         typedef std::vector<T> C;
         C::iterator i;
         C::const_iterator j;
+        (void) i;
+        (void) j;
     }
 #if TEST_STD_VER >= 11
     {
@@ -101,6 +103,8 @@ int main(int, char**)
         typedef std::vector<T, min_allocator<T>> C;
         C::iterator i;
         C::const_iterator j;
+        (void) i;
+        (void) j;
     }
 #endif
 #if TEST_STD_VER > 11
@@ -130,5 +134,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
index a554ec8ab0162..0e65d9896f402 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test_allocator_statistics alloc_stats;
     {
@@ -91,5 +91,14 @@ int main(int, char**)
       }
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
index f7e2865089d7b..1f41657eb56ea 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
@@ -73,5 +73,14 @@ int main(int, char**)
         assert(l2.get_allocator() == min_allocator<bool>());
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
index efa6ca183adc2..618357120c6bd 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<bool> d;
@@ -39,5 +39,14 @@ int main(int, char**)
     assert(d[3] == true);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
index b49dd1151b284..25f8fb6b29dfe 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         bool a[] = {0, 1, 1, 0, 1, 0, 0};
@@ -47,5 +47,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
index c41bac188364c..8879d1f1d358c 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp
@@ -16,7 +16,7 @@
 
 #include "test_macros.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
 
     bool a[] = {false, true, false, true};
@@ -36,5 +36,14 @@ int main(int, char**)
     assert( r1);
     assert(!r2);
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
index ae2305a9195e8..64dcc3c608214 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_bool.pass.cpp
@@ -15,7 +15,7 @@
 
 #include "test_macros.h"
 
-bool test() {
+TEST_CONSTEXPR_CXX20 bool test() {
   std::vector<bool> vec;
   typedef std::vector<bool>::reference Ref;
   vec.push_back(true);
@@ -47,6 +47,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp
index d56342a9e9f56..bcccb20318ded 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/assign_copy.pass.cpp
@@ -13,7 +13,9 @@
 #include <cassert>
 #include <vector>
 
-bool test() {
+#include "test_macros.h"
+
+TEST_CONSTEXPR_CXX20 bool test() {
   std::vector<bool> vec;
   typedef std::vector<bool>::reference Ref;
   vec.push_back(true);
@@ -71,6 +73,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp
index 0348b47bc2603..46ac18ab493b7 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/ctor_copy.pass.cpp
@@ -13,7 +13,9 @@
 #include <cassert>
 #include <vector>
 
-bool test() {
+#include "test_macros.h"
+
+TEST_CONSTEXPR_CXX20 bool test() {
   std::vector<bool> vec;
   typedef std::vector<bool>::reference Ref;
   vec.push_back(true);
@@ -28,6 +30,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp
index 8890fbfbb4df0..080975656ac9e 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/flip.pass.cpp
@@ -13,7 +13,9 @@
 #include <cassert>
 #include <vector>
 
-bool test() {
+#include "test_macros.h"
+
+TEST_CONSTEXPR_CXX20 bool test() {
   std::vector<bool> vec;
   typedef std::vector<bool>::reference Ref;
   vec.push_back(true);
@@ -33,6 +35,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp
index 8d9d616199deb..02abd0e6be766 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reference/operator_bool.pass.cpp
@@ -14,7 +14,9 @@
 #include <type_traits>
 #include <vector>
 
-bool test() {
+#include "test_macros.h"
+
+TEST_CONSTEXPR_CXX20 bool test() {
   std::vector<bool> vec;
   typedef std::vector<bool>::reference Ref;
   static_assert(std::is_convertible<Ref, bool>::value, "");
@@ -33,6 +35,9 @@ bool test() {
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
 
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
index 6b9ceca2b1882..e179fb95aac22 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
@@ -19,7 +19,7 @@
 #include "min_allocator.h"
 #include "test_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v;
@@ -59,7 +59,7 @@ int main(int, char**)
     }
 #endif
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    {
+    if (!TEST_IS_CONSTANT_EVALUATED) {
         std::vector<bool, limited_allocator<bool, 10> > v;
         v.reserve(5);
         try {
@@ -76,5 +76,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
index d032247a97a87..ef83dbf0a9741 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -54,5 +54,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
index 9cc7e2c98d70c..fa7ae3d3420a4 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -50,5 +50,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
index 7ec8e66fbea45..b39245cab7bf4 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v(100);
@@ -36,5 +36,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
index db737c930c359..33f8b72dd4722 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/size.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     typedef std::vector<bool> C;
@@ -59,5 +59,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp
index 6dbd08cea9520..edd28ef308471 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp
@@ -17,7 +17,7 @@
 #include "test_allocator.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<bool> v1(100);
@@ -96,5 +96,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
index 04380c9764e7d..b927f2a4dbdde 100644
--- a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
@@ -24,7 +24,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     typedef std::vector<bool> T;
@@ -56,5 +56,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/access.pass.cpp b/libcxx/test/std/containers/sequences/vector/access.pass.cpp
index 27d6e319460fb..5989f1e037fd3 100644
--- a/libcxx/test/std/containers/sequences/vector/access.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/access.pass.cpp
@@ -29,9 +29,7 @@
 #include "test_macros.h"
 
 template <class C>
-C
-make(int size, int start)
-{
+TEST_CONSTEXPR_CXX20 C make(int size, int start) {
     C c;
     for (int i = 0; i < size; ++i)
         c.push_back(start + i);
@@ -39,7 +37,7 @@ make(int size, int start)
 }
 
 template <class Vector>
-void test_get_basic(Vector& c, int start_value) {
+TEST_CONSTEXPR_CXX20 void test_get_basic(Vector& c, int start_value) {
     const int n = static_cast<int>(c.size());
     for (int i = 0; i < n; ++i)
         assert(c[i] == start_value + i);
@@ -47,10 +45,12 @@ void test_get_basic(Vector& c, int start_value) {
         assert(c.at(i) == start_value + i);
 
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    try {
-        TEST_IGNORE_NODISCARD c.at(n);
-        assert(false);
-    } catch (const std::out_of_range&) {}
+    if (!TEST_IS_CONSTANT_EVALUATED) {
+        try {
+            TEST_IGNORE_NODISCARD c.at(n);
+            assert(false);
+        } catch (const std::out_of_range&) {}
+    }
 #endif
 
     assert(c.front() == start_value);
@@ -58,7 +58,7 @@ void test_get_basic(Vector& c, int start_value) {
 }
 
 template <class Vector>
-void test_get() {
+TEST_CONSTEXPR_CXX20 void test_get() {
     int start_value = 35;
     Vector c = make<Vector>(10, start_value);
     const Vector& cc = c;
@@ -67,7 +67,7 @@ void test_get() {
 }
 
 template <class Vector>
-void test_set() {
+TEST_CONSTEXPR_CXX20 void test_set() {
     int start_value = 35;
     const int n = 10;
     Vector c = make<Vector>(n, start_value);
@@ -93,7 +93,7 @@ void test_set() {
 }
 
 template <class Vector>
-void test() {
+TEST_CONSTEXPR_CXX20 void test() {
     test_get<Vector>();
     test_set<Vector>();
 
@@ -112,12 +112,18 @@ void test() {
     ASSERT_SAME_TYPE(typename Vector::const_reference, decltype(cc.back()));
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     test<std::vector<int> >();
 #if TEST_STD_VER >= 11
     test<std::vector<int, min_allocator<int> > >();
 #endif
+    return true;
+}
 
-  return 0;
+int main(int, char**) {
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/compare.pass.cpp b/libcxx/test/std/containers/sequences/vector/compare.pass.cpp
index 21ffb9296fa52..917095e1f138d 100644
--- a/libcxx/test/std/containers/sequences/vector/compare.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/compare.pass.cpp
@@ -20,7 +20,7 @@
 
 #include "test_comparisons.h"
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
     {
         const std::vector<int> c1, c2;
         assert(testComparisons(c1, c2, true, false));
@@ -116,5 +116,14 @@ int main(int, char**) {
         assert((std::vector<int>() >= std::vector<int>()));
     }
 
+    return true;
+}
+
+int main(int, char**) {
+    test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp b/libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp
new file mode 100644
index 0000000000000..7a23a2d478a23
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/constant_initialization.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03
+// XFAIL: libcpp-has-debug-mode
+
+#include <algorithm>
+#include <vector>
+
+std::vector<int> ca_allocs;
+
+int main(int, char**) {
+  ca_allocs.push_back(0);
+  for ([[maybe_unused]] const auto& a : ca_allocs)
+    ;
+
+  return 0;
+}

diff  --git a/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp b/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp
index 21b90a698842e..d9f557e6c9770 100644
--- a/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/contiguous.pass.cpp
@@ -18,13 +18,13 @@
 #include "min_allocator.h"
 
 template <class C>
-void test_contiguous ( const C &c )
+TEST_CONSTEXPR_CXX20 void test_contiguous(const C &c)
 {
     for ( size_t i = 0; i < c.size(); ++i )
         assert ( *(c.begin() + static_cast<typename C::
diff erence_type>(i)) == *(std::addressof(*c.begin()) + i));
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     typedef int T;
@@ -50,5 +50,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp b/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp
index 3734893bfc570..c0003acae75ef 100644
--- a/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/get_allocator.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_allocator.h"
 #include "test_macros.h"
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
     {
         std::allocator<int> alloc;
         const std::vector<int> v(alloc);
@@ -30,5 +30,14 @@ int main(int, char**) {
         assert(v.get_allocator() == alloc);
     }
 
+    return true;
+}
+
+int main(int, char**) {
+    test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
index 296c551f76f67..70e0e35767e09 100644
--- a/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
@@ -28,7 +28,7 @@ struct A
     int second;
 };
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         typedef int T;
@@ -167,5 +167,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp
index c2b5d4d481e54..1591f912f3372 100644
--- a/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/reverse_iterators.pass.cpp
@@ -22,7 +22,7 @@
 #include "min_allocator.h"
 
 template <class Vector>
-void check_vector_reverse_iterators() {
+TEST_CONSTEXPR_CXX20 void check_vector_reverse_iterators() {
     {
         Vector vec;
         assert(vec.rbegin() == vec.rend());
@@ -67,11 +67,20 @@ void check_vector_reverse_iterators() {
     }
 }
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
     check_vector_reverse_iterators<std::vector<int> >();
 #if TEST_STD_VER >= 11
     check_vector_reverse_iterators<std::vector<int, min_allocator<int> > >();
 #endif
 
+    return true;
+}
+
+int main(int, char**) {
+    test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
index 41d885f250e03..b2eb33c6c5f53 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
@@ -17,7 +17,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<int> v;
@@ -46,5 +46,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
index cce2602bd360b..cc5f3bc90a670 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/empty.pass.cpp
@@ -18,8 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
     typedef std::vector<int> C;
     C c;
@@ -43,5 +42,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
index c9cc6d5821c4f..3f8d62e2f2d6b 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/max_size.pass.cpp
@@ -19,7 +19,7 @@
 #include "test_macros.h"
 
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
   {
     typedef limited_allocator<int, 10> A;
     typedef std::vector<int, A> C;
@@ -45,5 +45,15 @@ int main(int, char**) {
     assert(c.max_size() <= alloc_max_size(c.get_allocator()));
   }
 
+  return true;
+}
+
+int main(int, char**) {
+  test();
+
+#if TEST_STD_VER > 17
+  static_assert(test());
+#endif
+
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
index 3f4aadae3a2fa..99c489601b0f5 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
@@ -18,8 +18,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v;
         v.reserve(10);
@@ -50,7 +49,7 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(v));
     }
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    {
+    if (!TEST_IS_CONSTANT_EVALUATED) {
         std::vector<int> v;
         size_t sz = v.max_size() + 1;
 
@@ -62,7 +61,7 @@ int main(int, char**)
             assert(v.capacity() == 0);
         }
     }
-    {
+    if (!TEST_IS_CONSTANT_EVALUATED) {
         std::vector<int> v(10, 42);
         int* previous_data = v.data();
         size_t previous_capacity = v.capacity();
@@ -102,7 +101,7 @@ int main(int, char**)
     }
 #endif
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    {
+    if (!TEST_IS_CONSTANT_EVALUATED) {
         std::vector<int, limited_allocator<int, 100> > v;
         v.reserve(50);
         assert(v.capacity() == 50);
@@ -118,5 +117,16 @@ int main(int, char**)
     }
 #endif
 
+    return true;
+}
+
+int main(int, char**)
+{
+  tests();
+
+#if TEST_STD_VER > 17
+  static_assert(tests());
+#endif
+
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
index 41188acb7d893..0b9db8e691c08 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
@@ -19,8 +19,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v(100);
         v.resize(50);
@@ -81,5 +80,16 @@ int main(int, char**)
     }
 #endif
 
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
index 726ff8a7abef8..c0197982b4a45 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
@@ -17,8 +17,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v(100);
         v.resize(50, 1);
@@ -75,5 +74,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
index feb706653ca83..3f2487948430d 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -17,8 +17,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v(100);
         v.push_back(1);
@@ -38,7 +37,7 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(v));
     }
 #ifndef TEST_HAS_NO_EXCEPTIONS
-    {
+    if (!TEST_IS_CONSTANT_EVALUATED) {
         std::vector<int, limited_allocator<int, 400> > v(100);
         v.push_back(1);
         assert(is_contiguous_container_asan_correct(v));
@@ -60,5 +59,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
index 373a7069f3a91..aa41da69b31ab 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/size.pass.cpp
@@ -18,7 +18,7 @@
 #include "test_macros.h"
 #include "min_allocator.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     typedef std::vector<int> C;
@@ -59,5 +59,14 @@ int main(int, char**)
     }
 #endif
 
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
index 33df254c11696..47a0435674136 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
@@ -17,8 +17,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v1(100);
         std::vector<int> v2(200);
@@ -48,5 +47,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
index a14f90c0525da..f5b461b05a349 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
@@ -17,8 +17,7 @@
 #include "min_allocator.h"
 #include "allocators.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
         std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@@ -81,5 +80,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
index ba5a102d5e053..19a1b77603552 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
@@ -20,7 +20,7 @@
 #include "asan_testing.h"
 
 template <typename Vec>
-void test ( Vec &v )
+TEST_CONSTEXPR_CXX20 void test(Vec &v)
 {
     v.assign({3, 4, 5, 6});
     assert(v.size() == 4);
@@ -31,8 +31,7 @@ void test ( Vec &v )
     assert(v[3] == 6);
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
     typedef std::vector<int> V;
     V d1;
@@ -50,5 +49,14 @@ int main(int, char**)
     test(d2);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
index 6a572fada2c01..4daa320673ba2 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
@@ -23,7 +23,7 @@
 #endif
 
 
-void test() {
+TEST_CONSTEXPR_CXX20 bool test() {
 #if TEST_STD_VER >= 11
   int arr1[] = {42};
   int arr2[] = {1, 101, 42};
@@ -77,9 +77,14 @@ void test() {
     dst.assign(It(src.data()), It(src.data() + src.size()));
     assert(dst == src);
   }
+
+  return true;
 }
 
 int main(int, char**) {
   test();
+#if TEST_STD_VER > 17
+  static_assert(test());
+#endif
   return 0;
 }

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 3e25dc931f8fa..e6eba51a43bbb 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
@@ -20,8 +20,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
         std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@@ -97,5 +96,14 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(l2));
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
index 37e85a1462066..896aa40c0db95 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp
@@ -18,10 +18,10 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-bool is6(int x) { return x == 6; }
+TEST_CONSTEXPR bool is6(int x) { return x == 6; }
 
 template <typename Vec>
-void test ( Vec &v )
+TEST_CONSTEXPR_CXX20 void test(Vec &v)
 {
     v.assign(5, 6);
     assert(v.size() == 5);
@@ -29,8 +29,7 @@ void test ( Vec &v )
     assert(std::all_of(v.begin(), v.end(), is6));
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
     typedef std::vector<int> V;
     V d1;
@@ -56,5 +55,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
index 346c357d3f3ed..9a135b64a336c 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -22,8 +22,7 @@
 #include "asan_testing.h"
 
 template <class C>
-void
-test0()
+TEST_CONSTEXPR_CXX20 void test0()
 {
 #if TEST_STD_VER > 14
     static_assert((noexcept(C{})), "" );
@@ -45,8 +44,7 @@ test0()
 }
 
 template <class C>
-void
-test1(const typename C::allocator_type& a)
+TEST_CONSTEXPR_CXX20 void test1(const typename C::allocator_type& a)
 {
 #if TEST_STD_VER > 14
     static_assert((noexcept(C{typename C::allocator_type{}})), "" );
@@ -60,8 +58,7 @@ test1(const typename C::allocator_type& a)
     LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
     test0<std::vector<int> >();
     test0<std::vector<NotConstructible> >();
@@ -99,5 +96,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
index c7702d9f3d166..0f2fb36aaa67a 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -25,7 +25,7 @@
 #endif
 
 template <class C, class Iterator>
-void test(Iterator first, Iterator last) {
+TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last) {
   {
     C c(first, last);
     LIBCPP_ASSERT(c.__invariants());
@@ -44,7 +44,7 @@ void test(Iterator first, Iterator last) {
   }
 }
 
-static void basic_test_cases() {
+TEST_CONSTEXPR_CXX20 void basic_test_cases() {
   int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
   int* an = a + sizeof(a) / sizeof(a[0]);
   test<std::vector<int> >(cpp17_input_iterator<const int*>(a),
@@ -84,7 +84,7 @@ static void basic_test_cases() {
 #endif
 }
 
-void emplaceable_concept_tests() {
+TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
 #if TEST_STD_VER >= 11
   int arr1[] = {42};
   int arr2[] = {1, 101, 42};
@@ -160,7 +160,7 @@ struct B2 { int y; };
 struct Der : B1, B2 { int z; };
 
 // Initialize a vector with a 
diff erent value type.
-void test_ctor_with_
diff erent_value_type() {
+TEST_CONSTEXPR_CXX20 void test_ctor_with_
diff erent_value_type() {
   {
     // Make sure initialization is performed with each element value, not with
     // a memory blob.
@@ -189,12 +189,20 @@ void test_ctor_with_
diff erent_value_type() {
   }
 }
 
-
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool tests() {
   basic_test_cases();
   emplaceable_concept_tests(); // See PR34898
-  test_ctor_under_alloc();
   test_ctor_with_
diff erent_value_type();
 
-  return 0;
+  return true;
+}
+
+int main(int, char**)
+{
+    tests();
+    test_ctor_under_alloc();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
index ff68c56ac671e..5d38543963e5c 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
@@ -26,7 +26,7 @@
 #endif
 
 template <class C, class Iterator, class A>
-void test(Iterator first, Iterator last, const A& a) {
+TEST_CONSTEXPR_CXX20 void test(Iterator first, Iterator last, const A& a) {
   C c(first, last, a);
   LIBCPP_ASSERT(c.__invariants());
   assert(c.size() == static_cast<std::size_t>(std::distance(first, last)));
@@ -40,16 +40,16 @@ void test(Iterator first, Iterator last, const A& a) {
 
 template <class T>
 struct implicit_conv_allocator : min_allocator<T> {
-  implicit_conv_allocator(void*) {}
-  implicit_conv_allocator(const implicit_conv_allocator&) = default;
+  TEST_CONSTEXPR implicit_conv_allocator(void*) {}
+  TEST_CONSTEXPR implicit_conv_allocator(const implicit_conv_allocator&) = default;
 
   template <class U>
-  implicit_conv_allocator(implicit_conv_allocator<U>) {}
+  TEST_CONSTEXPR implicit_conv_allocator(implicit_conv_allocator<U>) {}
 };
 
 #endif
 
-void basic_tests() {
+TEST_CONSTEXPR_CXX20 void basic_tests() {
   {
     int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
     int* an = a + sizeof(a) / sizeof(a[0]);
@@ -86,7 +86,7 @@ void basic_tests() {
 #endif
 }
 
-void emplaceable_concept_tests() {
+TEST_CONSTEXPR_CXX20 void emplaceable_concept_tests() {
 #if TEST_STD_VER >= 11
   int arr1[] = {42};
   int arr2[] = {1, 101, 42};
@@ -162,9 +162,18 @@ void test_ctor_under_alloc() {
 #endif
 }
 
-int main(int, char**) {
+TEST_CONSTEXPR_CXX20 bool test() {
   basic_tests();
   emplaceable_concept_tests(); // See PR34898
+
+  return true;
+}
+
+int main(int, char**) {
+  test();
+#if TEST_STD_VER > 17
+  static_assert(test());
+#endif
   test_ctor_under_alloc();
 
   return 0;

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
index a06031c564d8b..e4b1f431ae491 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
@@ -21,6 +21,7 @@
 #include "asan_testing.h"
 
 template <class C>
+TEST_CONSTEXPR_CXX20
 void test(typename C::size_type n,
           typename C::allocator_type const& a = typename C::allocator_type())
 {
@@ -52,24 +53,33 @@ void test(typename C::size_type n,
 #endif
 }
 
-void tests() {
+TEST_CONSTEXPR_CXX20 bool tests() {
     test<std::vector<int> >(0);
     test<std::vector<int> >(50);
+#if TEST_STD_VER >= 11
+    test<std::vector<int, min_allocator<int>>>(0);
+    test<std::vector<int, min_allocator<int>>>(50);
+#endif
+
+    return true;
+}
+
+int main(int, char**) {
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
     test<std::vector<DefaultOnly> >(0);
     test<std::vector<DefaultOnly> >(500);
     assert(DefaultOnly::count == 0);
+
 #if TEST_STD_VER >= 11
-    test<std::vector<int, min_allocator<int>>>(0);
-    test<std::vector<int, min_allocator<int>>>(50);
     test<std::vector<DefaultOnly, min_allocator<DefaultOnly>>>(0);
     test<std::vector<DefaultOnly, min_allocator<DefaultOnly>>>(500);
     test<std::vector<DefaultOnly, test_allocator<DefaultOnly>>>(0, test_allocator<DefaultOnly>(23));
     test<std::vector<DefaultOnly, test_allocator<DefaultOnly>>>(100, test_allocator<DefaultOnly>(23));
     assert(DefaultOnly::count == 0);
 #endif
-}
 
-int main(int, char**) {
-    tests();
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
index 2f71c35ebc32f..7f7777c2c97dc 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
@@ -19,7 +19,7 @@
 #include "asan_testing.h"
 
 template <class C>
-void
+TEST_CONSTEXPR_CXX20 void
 test(typename C::size_type n, const typename C::value_type& x)
 {
     C c(n, x);
@@ -30,8 +30,7 @@ test(typename C::size_type n, const typename C::value_type& x)
         assert(*i == x);
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     test<std::vector<int> >(0, 3);
     test<std::vector<int> >(50, 3);
     // Add 1 for implementations that dynamically allocate a container proxy.
@@ -43,5 +42,14 @@ int main(int, char**)
     test<std::vector<int, min_allocator<int>> >(50, 3);
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
index 0db579fd22ce9..17d3a5876bc5b 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
@@ -18,7 +18,7 @@
 #include "asan_testing.h"
 
 template <class C>
-void
+TEST_CONSTEXPR_CXX20 void
 test(typename C::size_type n, const typename C::value_type& x,
      const typename C::allocator_type& a)
 {
@@ -31,8 +31,7 @@ test(typename C::size_type n, const typename C::value_type& x,
         assert(*i == x);
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     test<std::vector<int> >(0, 3, std::allocator<int>());
     test<std::vector<int> >(50, 3, std::allocator<int>());
 #if TEST_STD_VER >= 11
@@ -40,5 +39,14 @@ int main(int, char**)
     test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
index b2553f9bdf922..88822e9c18357 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -19,7 +19,7 @@
 #include "asan_testing.h"
 
 template <class C>
-void
+TEST_CONSTEXPR_CXX20 void
 test(const C& x)
 {
     typename C::size_type s = x.size();
@@ -30,8 +30,7 @@ test(const C& x)
     LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
         int* an = a + sizeof(a)/sizeof(a[0]);
@@ -87,5 +86,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
index 1f07855165155..70434bcfc578c 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
@@ -19,7 +19,7 @@
 #include "asan_testing.h"
 
 template <class C>
-void
+TEST_CONSTEXPR_CXX20 void
 test(const C& x, const typename C::allocator_type& a)
 {
     typename C::size_type s = x.size();
@@ -30,8 +30,7 @@ test(const C& x, const typename C::allocator_type& a)
     LIBCPP_ASSERT(is_contiguous_container_asan_correct(c));
 }
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
         int* an = a + sizeof(a)/sizeof(a[0]);
@@ -71,5 +70,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp
index c876662bbbb2b..3aab782e38af5 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/deduct.pass.cpp
@@ -28,8 +28,7 @@
 
 struct A {};
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
 
 //  Test the explicit deduction guides
     {
@@ -143,5 +142,13 @@ int main(int, char**)
 
     SequenceContainerDeductionGuidesSfinaeAway<std::vector, std::vector<int>>();
 
+    return true;
+}
+
+int main(int, char**) {
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
     return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
index 449751af11156..310f9ccfc9c6c 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
@@ -22,5 +22,5 @@ struct X
 int main(int, char**)
 {
 
-  return 0;
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
index 2fbb6c178d29d..3bd4a169d5f92 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
@@ -30,8 +30,7 @@ struct some_alloc
     void allocate(size_t);
 };
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         typedef std::vector<MoveOnly> C;
         static_assert(std::is_nothrow_default_constructible<C>::value, "");
@@ -49,5 +48,14 @@ int main(int, char**)
         static_assert(!std::is_nothrow_default_constructible<C>::value, "");
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
index a0901858989ee..793475955506d 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
@@ -28,7 +28,7 @@ struct some_alloc
     void allocate(size_t);
 };
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         typedef std::vector<MoveOnly> C;
@@ -49,5 +49,14 @@ int main(int, char**)
     }
 #endif // _LIBCPP_VERSION
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
index 5f06bb7b42206..6454f87f7e8ab 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
@@ -18,7 +18,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<int> d = {3, 4, 5, 6};
@@ -39,5 +39,14 @@ int main(int, char**)
     assert(d[3] == 6);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
index c5cb997069692..157aefc5af823 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
@@ -20,7 +20,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
@@ -49,5 +49,14 @@ int main(int, char**)
     assert(is_contiguous_container_asan_correct(d));
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

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 046f09fd4967d..0f3e737c1709b 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
@@ -21,7 +21,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test_allocator_statistics alloc_stats;
     {
@@ -131,5 +131,14 @@ int main(int, char**)
       }
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

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 3f6b3fe425abd..2b6705a38e860 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
@@ -20,7 +20,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
@@ -95,5 +95,14 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(l2));
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
index 0f4538ae61c8e..fdd74a3f566b7 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
@@ -96,5 +96,5 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
index ac924c0bc1189..f3d7b6a21b62e 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
@@ -19,7 +19,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     std::vector<int> d;
@@ -42,5 +42,14 @@ int main(int, char**)
     assert(d[3] == 6);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
index 91eb2a2b324c5..4d2cadc00ceb1 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
@@ -18,15 +18,15 @@
 #include "asan_testing.h"
 
 struct Nasty {
-    Nasty() : i_(0) {}
-    Nasty(int i) : i_(i) {}
-    ~Nasty() {}
+    TEST_CONSTEXPR Nasty() : i_(0) {}
+    TEST_CONSTEXPR Nasty(int i) : i_(i) {}
+    TEST_CONSTEXPR_CXX20 ~Nasty() {}
 
     Nasty * operator&() const { assert(false); return nullptr; }
     int i_;
-    };
+};
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<int> v;
@@ -61,5 +61,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
index 2b76fe42d6e67..d314f90daf4b6 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -18,15 +18,15 @@
 #include "asan_testing.h"
 
 struct Nasty {
-    Nasty() : i_(0) {}
-    Nasty(int i) : i_(i) {}
-    ~Nasty() {}
+    TEST_CONSTEXPR Nasty() : i_(0) {}
+    TEST_CONSTEXPR Nasty(int i) : i_(i) {}
+    TEST_CONSTEXPR_CXX20 ~Nasty() {}
 
     Nasty * operator&() const { assert(false); return nullptr; }
     int i_;
-    };
+};
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         const std::vector<int> v;
@@ -61,5 +61,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp
index 141c55d2f113d..72441c12dac8e 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase.pass.cpp
@@ -21,16 +21,15 @@
 #include "min_allocator.h"
 
 template <class S, class U>
-void test0(S s, U val, S expected, size_t expected_erased_count) {
+TEST_CONSTEXPR_CXX20 void test0(S s, U val, S expected, size_t expected_erased_count) {
   ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase(s, val)));
   assert(expected_erased_count == std::erase(s, val));
   assert(s == expected);
 }
 
 template <class S>
-void test()
+TEST_CONSTEXPR_CXX20 void test()
 {
-
   test0(S(), 1, S(), 0);
 
   test0(S({1}), 1, S(), 1);
@@ -64,7 +63,7 @@ void test()
   test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test<std::vector<int>>();
     test<std::vector<int, min_allocator<int>>> ();
@@ -73,5 +72,14 @@ int main(int, char**)
     test<std::vector<long>>();
     test<std::vector<double>>();
 
+    return true;
+}
+
+int main(int, char**)
+{
+  tests();
+#if TEST_STD_VER > 17
+  static_assert(tests());
+#endif
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp
index 5934f634369e5..1fcc1c9424868 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.erasure/erase_if.pass.cpp
@@ -20,14 +20,14 @@
 #include "min_allocator.h"
 
 template <class S, class Pred>
-void test0(S s, Pred p, S expected, size_t expected_erased_count) {
+TEST_CONSTEXPR_CXX20 void test0(S s, Pred p, S expected, size_t expected_erased_count) {
   ASSERT_SAME_TYPE(typename S::size_type, decltype(std::erase_if(s, p)));
   assert(expected_erased_count == std::erase_if(s, p));
   assert(s == expected);
 }
 
 template <typename S>
-void test()
+TEST_CONSTEXPR_CXX20 void test()
 {
     auto is1 = [](auto v) { return v == 1;};
     auto is2 = [](auto v) { return v == 2;};
@@ -65,7 +65,7 @@ void test()
     test0(S({1, 2, 3}), False, S({1, 2, 3}), 0);
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     test<std::vector<int>>();
     test<std::vector<int, min_allocator<int>>> ();
@@ -74,5 +74,14 @@ int main(int, char**)
     test<std::vector<long>>();
     test<std::vector<double>>();
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
index 334c67adcfc67..5a1e134f66fdf 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/clear.pass.cpp
@@ -17,7 +17,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     int a[] = {1, 2, 3};
@@ -40,5 +40,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

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 bc85f3e2969a7..f2c656cd27b2f 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
@@ -28,10 +28,10 @@ class A
     A(const A&);
     A& operator=(const A&);
 public:
-    A(int i, double d)
+    TEST_CONSTEXPR_CXX14 A(int i, double d)
         : i_(i), d_(d) {}
 
-    A(A&& a)
+    TEST_CONSTEXPR_CXX14 A(A&& a)
         : i_(a.i_),
           d_(a.d_)
     {
@@ -39,7 +39,7 @@ class A
         a.d_ = 0;
     }
 
-    A& operator=(A&& a)
+    TEST_CONSTEXPR_CXX14 A& operator=(A&& a)
     {
         i_ = a.i_;
         d_ = a.d_;
@@ -48,11 +48,11 @@ class A
         return *this;
     }
 
-    int geti() const {return i_;}
-    double getd() const {return d_;}
+    TEST_CONSTEXPR_CXX14 int geti() const {return i_;}
+    TEST_CONSTEXPR_CXX14 double getd() const {return d_;}
 };
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<A> c;
@@ -133,5 +133,14 @@ int main(int, char**)
         assert(c.back().getd() == 4.5);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

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 5cf38f2f440f8..bb7fa745ac355 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
@@ -30,10 +30,10 @@ class A
     A(const A&) = delete;
     A& operator=(const A&) = delete;
 
-    A(int i, double d)
+    TEST_CONSTEXPR_CXX14 A(int i, double d)
         : i_(i), d_(d) {}
 
-    A(A&& a)
+    TEST_CONSTEXPR_CXX14 A(A&& a)
         : i_(a.i_),
           d_(a.d_)
     {
@@ -41,7 +41,7 @@ class A
         a.d_ = 0;
     }
 
-    A& operator=(A&& a)
+    TEST_CONSTEXPR_CXX14 A& operator=(A&& a)
     {
         i_ = a.i_;
         d_ = a.d_;
@@ -50,11 +50,11 @@ class A
         return *this;
     }
 
-    int geti() const {return i_;}
-    double getd() const {return d_;}
+    TEST_CONSTEXPR_CXX14 int geti() const {return i_;}
+    TEST_CONSTEXPR_CXX14 double getd() const {return d_;}
 };
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<A> c;
@@ -157,5 +157,14 @@ int main(int, char**)
         for (int i = 0; i < sz; ++i)
             assert(c[i] == i);
     }
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
index 5bc35be643de6..3e1a1d82c2ebb 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
@@ -19,8 +19,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool tests() {
     {
         std::vector<int> v;
         v.reserve(3);
@@ -71,5 +70,14 @@ int main(int, char**)
         assert(v.capacity() == old_capacity);
         assert(v[4] == 42);
     }
-  return 0;
+
+    return true;
+}
+
+int main(int, char**) {
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
index 423deff4a878f..43d843e24a11b 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -33,7 +33,7 @@ struct Throws {
 bool Throws::sThrows = false;
 #endif
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
     int a1[] = {1, 2, 3, 4, 5};
@@ -102,19 +102,30 @@ int main(int, char**)
     assert(is_contiguous_container_asan_correct(l1));
     }
 #endif
+
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+
 #ifndef TEST_HAS_NO_EXCEPTIONS
 // Test for LWG2853:
 // Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T.
     {
-    Throws arr[] = {1, 2, 3};
-    std::vector<Throws> v(arr, arr+3);
-    Throws::sThrows = true;
-    v.erase(v.begin());
-    v.erase(--v.end());
-    v.erase(v.begin());
-    assert(v.size() == 0);
+        Throws arr[] = {1, 2, 3};
+        std::vector<Throws> v(arr, arr+3);
+        Throws::sThrows = true;
+        v.erase(v.begin());
+        v.erase(--v.end());
+        v.erase(v.begin());
+        assert(v.size() == 0);
     }
 #endif
 
-  return 0;
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
index 0025e7610368b..7857b8868a4c0 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
@@ -33,7 +33,7 @@ struct Throws {
 bool Throws::sThrows = false;
 #endif
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     int a1[] = {1, 2, 3};
     {
@@ -140,19 +140,30 @@ int main(int, char**)
         assert(is_contiguous_container_asan_correct(outer[1]));
     }
 #endif
+
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+
 #ifndef TEST_HAS_NO_EXCEPTIONS
 // Test for LWG2853:
 // Throws: Nothing unless an exception is thrown by the assignment operator or move assignment operator of T.
     {
-    Throws arr[] = {1, 2, 3};
-    std::vector<Throws> v(arr, arr+3);
-    Throws::sThrows = true;
-    v.erase(v.begin(), --v.end());
-    assert(v.size() == 1);
-    v.erase(v.begin(), v.end());
-    assert(v.size() == 0);
+        Throws arr[] = {1, 2, 3};
+        std::vector<Throws> v(arr, arr+3);
+        Throws::sThrows = true;
+        v.erase(v.begin(), --v.end());
+        assert(v.size() == 1);
+        v.erase(v.begin(), v.end());
+        assert(v.size() == 0);
     }
 #endif
 
-  return 0;
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
index 4a81fbfed65e7..92584892001a6 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
@@ -54,10 +54,8 @@ void test_throwing() {
 }
 #endif // TEST_HAS_NO_EXCEPTIONS
 
-int main(int, char**) {
-#ifndef TEST_HAS_NO_EXCEPTIONS
-  test_throwing();
-#endif
+TEST_CONSTEXPR_CXX20 bool tests()
+{
   {
     std::vector<int> d(10, 1);
     std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
@@ -101,5 +99,16 @@ int main(int, char**) {
     assert(d[13] == 1);
   }
 
+    return true;
+}
+
+int main(int, char**) {
+#ifndef TEST_HAS_NO_EXCEPTIONS
+  test_throwing();
+#endif
+  tests();
+#if TEST_STD_VER > 17
+  static_assert(tests());
+#endif
   return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
index ca8dcb8474c69..fe18d2da3b9e5 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
@@ -26,7 +26,7 @@ struct S {};
 void make_move_iterator(S*) {}
 }
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         typedef std::vector<int> V;
@@ -182,5 +182,14 @@ int main(int, char**)
         s.insert(s.end(), cpp17_input_iterator<adl::S*>(nullptr), cpp17_input_iterator<adl::S*>(nullptr));
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp
index 63c1c64e272a8..c8bb994258894 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_lvalue.pass.cpp
@@ -19,8 +19,8 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool test() {
+
     {
         std::vector<int> v(100);
         const int lvalue = 1;
@@ -116,5 +116,15 @@ int main(int, char**)
     }
 #endif
 
+    return true;
+}
+
+int main(int, char**)
+{
+    test();
+#if TEST_STD_VER > 17
+    static_assert(test());
+#endif
+
   return 0;
 }

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 fe03f2acfab28..11a7175c61967 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
@@ -21,7 +21,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<MoveOnly> v(100);
@@ -63,5 +63,14 @@ int main(int, char**)
             assert(v[j] == MoveOnly());
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
index 5b182f44d6adc..c629428828081 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
@@ -19,7 +19,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<int> v(100);
@@ -112,5 +112,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
index 386328405d01a..9482920f0fe60 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
@@ -18,7 +18,7 @@
 #include "min_allocator.h"
 
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<int> c;
@@ -50,5 +50,14 @@ int main(int, char**)
             assert(c[i] == i);
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
index dcb6d4448ed50..2490fded523d6 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
@@ -18,7 +18,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<int> c;
@@ -110,5 +110,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

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 e7527d44ca47f..92b629b3cdb4f 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
@@ -21,7 +21,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         std::vector<MoveOnly> c;
@@ -111,5 +111,14 @@ int main(int, char**)
             assert(c[j] == MoveOnly(j));
     }
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
index 5866d2c130c61..e1f45208539ac 100644
--- a/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -19,7 +19,7 @@
 #include "min_allocator.h"
 #include "asan_testing.h"
 
-int main(int, char**)
+TEST_CONSTEXPR_CXX20 bool tests()
 {
     {
         int a1[] = {1, 3, 7, 9, 10};
@@ -180,5 +180,14 @@ int main(int, char**)
     }
 #endif
 
-  return 0;
+    return true;
+}
+
+int main(int, char**)
+{
+    tests();
+#if TEST_STD_VER > 17
+    static_assert(tests());
+#endif
+    return 0;
 }

diff  --git a/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp b/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
index 4942372246811..105ca8a510336 100644
--- a/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
+++ b/libcxx/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
@@ -8,6 +8,8 @@
 
 // UNSUPPORTED: c++03, c++11
 
+// XFAIL: libcpp-has-debug-mode
+
 #include <experimental/coroutine>
 #include <vector>
 #include <cassert>

diff  --git a/libcxx/test/support/allocators.h b/libcxx/test/support/allocators.h
index fce43acf129be..f4578da74ffca 100644
--- a/libcxx/test/support/allocators.h
+++ b/libcxx/test/support/allocators.h
@@ -9,6 +9,7 @@
 #ifndef ALLOCATORS_H
 #define ALLOCATORS_H
 
+#include <memory>
 #include <type_traits>
 #include <utility>
 
@@ -201,8 +202,8 @@ class MaybePOCCAAllocator {
         typedef MaybePOCCAAllocator<U, POCCAValue> other;
     };
 
-    MaybePOCCAAllocator() = default;
-    MaybePOCCAAllocator(int id, bool* copy_assigned_into)
+    TEST_CONSTEXPR MaybePOCCAAllocator() = default;
+    TEST_CONSTEXPR MaybePOCCAAllocator(int id, bool* copy_assigned_into)
         : id_(id), copy_assigned_into_(copy_assigned_into) {}
 
     template <class U>
@@ -210,7 +211,7 @@ class MaybePOCCAAllocator {
         : id_(that.id_), copy_assigned_into_(that.copy_assigned_into_) {}
 
     MaybePOCCAAllocator(const MaybePOCCAAllocator&) = default;
-    MaybePOCCAAllocator& operator=(const MaybePOCCAAllocator& a)
+    TEST_CONSTEXPR_CXX14 MaybePOCCAAllocator& operator=(const MaybePOCCAAllocator& a)
     {
         id_ = a.id();
         if (copy_assigned_into_)
@@ -218,26 +219,26 @@ class MaybePOCCAAllocator {
         return *this;
     }
 
-    T* allocate(std::size_t n)
+    TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n)
     {
-        return static_cast<T*>(::operator new(n * sizeof(T)));
+        return std::allocator<T>().allocate(n);
     }
 
-    void deallocate(T* ptr, std::size_t)
+    TEST_CONSTEXPR_CXX20 void deallocate(T* ptr, std::size_t n)
     {
-        ::operator delete(ptr);
+        std::allocator<T>().deallocate(ptr, n);
     }
 
-    int id() const { return id_; }
+    TEST_CONSTEXPR int id() const { return id_; }
 
     template <class U>
-    friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
+    TEST_CONSTEXPR friend bool operator==(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
     {
         return lhs.id() == rhs.id();
     }
 
     template <class U>
-    friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
+    TEST_CONSTEXPR friend bool operator!=(const MaybePOCCAAllocator& lhs, const MaybePOCCAAllocator<U, POCCAValue>& rhs)
     {
         return !(lhs == rhs);
     }

diff  --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h
index 7f3312d9f8223..aae93019fe1c6 100644
--- a/libcxx/test/support/asan_testing.h
+++ b/libcxx/test/support/asan_testing.h
@@ -16,17 +16,19 @@ extern "C" int __sanitizer_verify_contiguous_container
      ( const void *beg, const void *mid, const void *end );
 
 template <typename T, typename Alloc>
-bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
+TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &c )
 {
-    if ( std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
-        return __sanitizer_verify_contiguous_container (
+    if (std::__libcpp_is_constant_evaluated())
+        return true;
+    if (std::is_same<Alloc, std::allocator<T> >::value && c.data() != NULL)
+        return __sanitizer_verify_contiguous_container(
             c.data(), c.data() + c.size(), c.data() + c.capacity()) != 0;
     return true;
 }
 
 #else
 template <typename T, typename Alloc>
-bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &)
+TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T, Alloc> &)
 {
     return true;
 }

diff  --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h
index c39be5f0428b3..cbf36e03964c4 100644
--- a/libcxx/test/support/poisoned_hash_helper.h
+++ b/libcxx/test/support/poisoned_hash_helper.h
@@ -24,10 +24,10 @@ template <class ...Args> struct TypeList;
 
 // Test that the specified Hash meets the requirements of an enabled hash
 template <class Hash, class Key, class InputKey = Key>
-void test_hash_enabled(InputKey const& key = InputKey{});
+TEST_CONSTEXPR_CXX20 void test_hash_enabled(InputKey const& key = InputKey{});
 
 template <class T, class InputKey = T>
-void test_hash_enabled_for_type(InputKey const& key = InputKey{}) {
+TEST_CONSTEXPR_CXX20 void test_hash_enabled_for_type(InputKey const& key = InputKey{}) {
   return test_hash_enabled<std::hash<T>, T, InputKey>(key);
 }
 
@@ -129,7 +129,7 @@ constexpr bool can_hash() {
 } // namespace PoisonedHashDetail
 
 template <class Hash, class Key, class InputKey>
-void test_hash_enabled(InputKey const& key) {
+TEST_CONSTEXPR_CXX20 void test_hash_enabled(InputKey const& key) {
   using namespace PoisonedHashDetail;
 
   static_assert(std::is_destructible<Hash>::value, "");

diff  --git a/libcxx/test/support/test_allocator.h b/libcxx/test/support/test_allocator.h
index 741f6fc2f5324..3b9676ee17526 100644
--- a/libcxx/test/support/test_allocator.h
+++ b/libcxx/test/support/test_allocator.h
@@ -21,7 +21,7 @@
 #include "test_macros.h"
 
 template <class Alloc>
-inline typename std::allocator_traits<Alloc>::size_type alloc_max_size(Alloc const& a) {
+TEST_CONSTEXPR_CXX20 inline typename std::allocator_traits<Alloc>::size_type alloc_max_size(Alloc const& a) {
   typedef std::allocator_traits<Alloc> AT;
   return AT::max_size(a);
 }
@@ -165,8 +165,12 @@ class test_allocator {
   TEST_CONSTEXPR size_type max_size() const TEST_NOEXCEPT { return UINT_MAX / sizeof(T); }
 
   template <class U>
-  TEST_CONSTEXPR_CXX14 void construct(pointer p, U&& val) {
+  TEST_CONSTEXPR_CXX20 void construct(pointer p, U&& val) {
+#if TEST_STD_VER > 17
+    std::construct_at(std::to_address(p), std::forward<U>(val));
+#else
     ::new (static_cast<void*>(p)) T(std::forward<U>(val));
+#endif
   }
 
   TEST_CONSTEXPR_CXX14 void destroy(pointer p) { p->~T(); }
@@ -399,12 +403,16 @@ class TaggingAllocator {
   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)...);
+  TEST_CONSTEXPR_CXX20 void construct(Tag_X* p, Args&&... args) {
+#if TEST_STD_VER > 17
+    std::construct_at(p, Ctor_Tag{}, std::forward<Args>(args)...);
+#else
+    ::new (static_cast<void*>(p)) Tag_X(Ctor_Tag(), std::forward<Args>(args)...);
+#endif
   }
 
   template <typename U>
-  void destroy(U* p) {
+  TEST_CONSTEXPR_CXX20 void destroy(U* p) {
     p->~U();
   }
 
@@ -421,9 +429,10 @@ struct limited_alloc_handle {
   TEST_CONSTEXPR_CXX20 T* allocate(std::size_t N) {
     if (N + outstanding_ > MaxAllocs)
       TEST_THROW(std::bad_alloc());
-    last_alloc_ = std::allocator<T>().allocate(N);
+    auto alloc = std::allocator<T>().allocate(N);
+    last_alloc_ = alloc;
     outstanding_ += N;
-    return static_cast<T*>(last_alloc_);
+    return alloc;
   }
 
   template <class T>


        


More information about the llvm-branch-commits mailing list