[libcxx-commits] [libcxx] [libc++] Make list constexpr as part of P3372R3 (PR #129799)
Peng Liu via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 5 20:38:28 PST 2025
https://github.com/winner245 updated https://github.com/llvm/llvm-project/pull/129799
>From aaa55cfbbd05681c4d8c85e26459a24a4a6ead2f Mon Sep 17 00:00:00 2001
From: Peng Liu <winner245 at hotmail.com>
Date: Sat, 1 Mar 2025 12:37:25 -0500
Subject: [PATCH 1/2] Make list constexpr as part of P3372R3
---
libcxx/docs/FeatureTestMacroTable.rst | 2 +
libcxx/include/__memory/allocation_guard.h | 20 +-
libcxx/include/__memory/pointer_traits.h | 8 +
libcxx/include/list | 562 ++++++++-------
libcxx/include/version | 2 +
.../sequences/list/compare.pass.cpp | 24 +-
.../sequences/list/compare.three_way.pass.cpp | 6 +-
.../sequences/list/get_allocator.pass.cpp | 13 +-
.../sequences/list/incomplete_type.pass.cpp | 13 +-
.../sequences/list/iterators.pass.cpp | 27 +-
.../list/list.capacity/empty.pass.cpp | 13 +-
.../list/list.capacity/max_size.pass.cpp | 13 +-
.../list/list.capacity/resize_size.pass.cpp | 63 +-
.../list.capacity/resize_size_value.pass.cpp | 13 +-
.../list/list.capacity/size.pass.cpp | 13 +-
.../list/list.cons/assign_copy.pass.cpp | 13 +-
.../assign_initializer_list.pass.cpp | 13 +-
.../list/list.cons/assign_move.pass.cpp | 13 +-
.../sequences/list/list.cons/copy.pass.cpp | 13 +-
.../list/list.cons/copy_alloc.pass.cpp | 13 +-
.../sequences/list/list.cons/default.pass.cpp | 13 +-
.../list.cons/default_stack_alloc.pass.cpp | 13 +-
.../list/list.cons/from_range.pass.cpp | 20 +-
.../list/list.cons/initializer_list.pass.cpp | 13 +-
.../list.cons/initializer_list_alloc.pass.cpp | 13 +-
.../list/list.cons/input_iterator.pass.cpp | 31 +-
.../sequences/list/list.cons/move.pass.cpp | 13 +-
.../list/list.cons/move_alloc.pass.cpp | 13 +-
.../op_equal_initializer_list.pass.cpp | 13 +-
.../list/list.cons/size_type.pass.cpp | 40 +-
.../list/list.cons/size_value_alloc.pass.cpp | 13 +-
.../list/list.erasure/erase.pass.cpp | 27 +-
.../list/list.erasure/erase_if.pass.cpp | 27 +-
.../list/list.modifiers/append_range.pass.cpp | 20 +-
.../list/list.modifiers/assign_range.pass.cpp | 20 +-
.../list/list.modifiers/clear.pass.cpp | 13 +-
.../list/list.modifiers/emplace.pass.cpp | 19 +-
.../list/list.modifiers/emplace_back.pass.cpp | 19 +-
.../list.modifiers/emplace_front.pass.cpp | 19 +-
.../list/list.modifiers/erase_iter.pass.cpp | 13 +-
.../list.modifiers/erase_iter_iter.pass.cpp | 13 +-
.../insert_iter_initializer_list.pass.cpp | 13 +-
.../insert_iter_iter_iter.pass.cpp | 59 +-
.../insert_iter_rvalue.pass.cpp | 13 +-
.../insert_iter_size_value.pass.cpp | 33 +-
.../list.modifiers/insert_iter_value.pass.cpp | 33 +-
.../list/list.modifiers/insert_range.pass.cpp | 23 +-
.../list/list.modifiers/pop_back.pass.cpp | 13 +-
.../list/list.modifiers/pop_front.pass.cpp | 13 +-
.../list.modifiers/prepend_range.pass.cpp | 20 +-
.../list/list.modifiers/push_back.pass.cpp | 13 +-
.../list.modifiers/push_back_rvalue.pass.cpp | 13 +-
.../list/list.modifiers/push_front.pass.cpp | 13 +-
.../list.modifiers/push_front_rvalue.pass.cpp | 13 +-
.../sequences/list/list.ops/merge.pass.cpp | 13 +-
.../list/list.ops/merge_comp.pass.cpp | 13 +-
.../sequences/list/list.ops/remove.pass.cpp | 25 +-
.../list/list.ops/remove_if.pass.cpp | 25 +-
.../sequences/list/list.ops/reverse.pass.cpp | 13 +-
.../sequences/list/list.ops/sort.pass.cpp | 19 +-
.../list/list.ops/sort_comp.pass.cpp | 57 +-
.../list/list.ops/splice_pos_list.pass.cpp | 13 +-
.../list.ops/splice_pos_list_iter.pass.cpp | 13 +-
.../splice_pos_list_iter_iter.pass.cpp | 13 +-
.../sequences/list/list.ops/unique.pass.cpp | 13 +-
.../list/list.ops/unique_pred.pass.cpp | 23 +-
.../sequences/list/list.special/swap.pass.cpp | 13 +-
.../list/list.special/swap_noexcept.pass.cpp | 13 +-
.../list.version.compile.pass.cpp | 28 +
.../version.version.compile.pass.cpp | 28 +
libcxx/test/support/counting_predicates.h | 55 +-
libcxx/test/support/min_allocator.h | 650 +++++++++---------
.../generate_feature_test_macro_components.py | 5 +
73 files changed, 1663 insertions(+), 883 deletions(-)
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index dcf9838edd74b..6cc5cef2211a7 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -416,6 +416,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_bitset`` ``202306L``
---------------------------------------------------------- -----------------
+ ``__cpp_lib_constexpr_list`` ``202502L``
+ ---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_new`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_constrained_equality`` *unimplemented*
diff --git a/libcxx/include/__memory/allocation_guard.h b/libcxx/include/__memory/allocation_guard.h
index 66edcd92ed618..2fc485f4ed0ed 100644
--- a/libcxx/include/__memory/allocation_guard.h
+++ b/libcxx/include/__memory/allocation_guard.h
@@ -49,24 +49,26 @@ struct __allocation_guard {
using _Size _LIBCPP_NODEBUG = typename allocator_traits<_Alloc>::size_type;
template <class _AllocT> // we perform the allocator conversion inside the constructor
- _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __allocation_guard(_AllocT __alloc, _Size __n)
: __alloc_(std::move(__alloc)),
__n_(__n),
__ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important
{}
- _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__allocation_guard() _NOEXCEPT { __destroy(); }
- _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;
- _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(const __allocation_guard&) = delete;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard(__allocation_guard&& __other) _NOEXCEPT
: __alloc_(std::move(__other.__alloc_)),
__n_(__other.__n_),
__ptr_(__other.__ptr_) {
__other.__ptr_ = nullptr;
}
- _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(const __allocation_guard& __other) = delete;
- _LIBCPP_HIDE_FROM_ABI __allocation_guard& operator=(__allocation_guard&& __other) _NOEXCEPT {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
+ operator=(const __allocation_guard& __other) = delete;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __allocation_guard&
+ operator=(__allocation_guard&& __other) _NOEXCEPT {
if (std::addressof(__other) != this) {
__destroy();
@@ -79,17 +81,17 @@ struct __allocation_guard {
return *this;
}
- _LIBCPP_HIDE_FROM_ABI _Pointer
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer
__release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++
_Pointer __tmp = __ptr_;
__ptr_ = nullptr;
return __tmp;
}
- _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Pointer __get() const _NOEXCEPT { return __ptr_; }
private:
- _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __destroy() _NOEXCEPT {
if (__ptr_ != nullptr) {
allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_);
}
diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index afe3d1bf8a2de..9626922ca3c2f 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -302,6 +302,14 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
#endif
+template <class _PtrTo, class _PtrFrom>
+_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
+ using __ptr_traits = pointer_traits<_PtrTo>;
+ using __element_type = typename __ptr_traits::element_type;
+ return __p ? __ptr_traits::pointer_to(*static_cast<__element_type*>(std::addressof(*__p)))
+ : static_cast<_PtrTo>(nullptr);
+}
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/list b/libcxx/include/list
index 1285174f1c384..27031b90a97e0 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -287,10 +287,14 @@ struct __list_node_pointer_traits {
"_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
# endif
- static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; }
+ static _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer
+ __unsafe_link_pointer_cast(__base_pointer __p) {
+ return __p;
+ }
- static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) {
- return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p));
+ static _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer
+ __unsafe_link_pointer_cast(__node_pointer __p) {
+ return std::__static_fancy_pointer_cast<__base_pointer>(__p);
}
};
@@ -303,14 +307,20 @@ struct __list_node_base {
__base_pointer __prev_;
__base_pointer __next_;
- _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_node_base() : __prev_(__self()), __next_(__self()) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26
_LIBCPP_HIDE_FROM_ABI explicit __list_node_base(__base_pointer __prev, __base_pointer __next)
: __prev_(__prev), __next_(__next) {}
- _LIBCPP_HIDE_FROM_ABI __base_pointer __self() { return pointer_traits<__base_pointer>::pointer_to(*this); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __self() {
+ return pointer_traits<__base_pointer>::pointer_to(*this);
+ }
- _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() { return static_cast<__node_pointer>(__self()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer __as_node() {
+ return pointer_traits<__node_pointer>::pointer_to(
+ *static_cast<typename pointer_traits<__node_pointer>::element_type*>(this));
+ }
};
template <class _Tp, class _VoidPtr>
@@ -325,7 +335,7 @@ private:
};
public:
- _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; }
# else
private:
@@ -338,10 +348,14 @@ public:
typedef __list_node_base<_Tp, _VoidPtr> __base;
typedef typename __base::__base_pointer __base_pointer;
- _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next) : __base(__prev, __next) {}
- _LIBCPP_HIDE_FROM_ABI ~__list_node() {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_node(__base_pointer __prev, __base_pointer __next)
+ : __base(__prev, __next) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_node() {}
- _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() { return __base::__self(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() {
+ return pointer_traits<__base_pointer>::pointer_to(
+ *static_cast<typename pointer_traits<__base_pointer>::element_type*>(this));
+ }
};
template <class _Tp, class _Alloc = allocator<_Tp> >
@@ -358,7 +372,8 @@ class _LIBCPP_TEMPLATE_VIS __list_iterator {
__base_pointer __ptr_;
- _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_iterator(__base_pointer __p) _NOEXCEPT
+ : __ptr_(__p) {}
template <class, class>
friend class list;
@@ -374,37 +389,41 @@ public:
typedef __rebind_pointer_t<_VoidPtr, value_type> pointer;
typedef typename pointer_traits<pointer>::difference_type difference_type;
- _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator() _NOEXCEPT : __ptr_(nullptr) {}
- _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }
- _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
+ return __ptr_->__as_node()->__get_value();
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
}
- _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator++() {
__ptr_ = __ptr_->__next_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator++(int) {
__list_iterator __t(*this);
++(*this);
return __t;
}
- _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator& operator--() {
__ptr_ = __ptr_->__prev_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_iterator operator--(int) {
__list_iterator __t(*this);
--(*this);
return __t;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_iterator& __x, const __list_iterator& __y) {
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
+ operator==(const __list_iterator& __x, const __list_iterator& __y) {
return __x.__ptr_ == __y.__ptr_;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_iterator& __x, const __list_iterator& __y) {
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
+ operator!=(const __list_iterator& __x, const __list_iterator& __y) {
return !(__x == __y);
}
};
@@ -416,7 +435,8 @@ class _LIBCPP_TEMPLATE_VIS __list_const_iterator {
__base_pointer __ptr_;
- _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT : __ptr_(__p) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit __list_const_iterator(__base_pointer __p) _NOEXCEPT
+ : __ptr_(__p) {}
template <class, class>
friend class list;
@@ -430,39 +450,43 @@ public:
typedef __rebind_pointer_t<_VoidPtr, const value_type> pointer;
typedef typename pointer_traits<pointer>::difference_type difference_type;
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT
- : __ptr_(__p.__ptr_) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
+ __list_const_iterator(const __list_iterator<_Tp, _VoidPtr>& __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
- _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __ptr_->__as_node()->__get_value(); }
- _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference operator*() const {
+ return __ptr_->__as_node()->__get_value();
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
return pointer_traits<pointer>::pointer_to(__ptr_->__as_node()->__get_value());
}
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator++() {
__ptr_ = __ptr_->__next_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator++(int) {
__list_const_iterator __t(*this);
++(*this);
return __t;
}
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator& operator--() {
__ptr_ = __ptr_->__prev_;
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_const_iterator operator--(int) {
__list_const_iterator __t(*this);
--(*this);
return __t;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) {
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
+ operator==(const __list_const_iterator& __x, const __list_const_iterator& __y) {
return __x.__ptr_ == __y.__ptr_;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) {
+ friend _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool
+ operator!=(const __list_const_iterator& __x, const __list_const_iterator& __y) {
return !(__x == __y);
}
};
@@ -503,43 +527,49 @@ protected:
__node_base __end_;
_LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);
- _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
- return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
+ return pointer_traits<__base_pointer>::pointer_to(const_cast<__node_base&>(__end_));
}
- _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
return __node_alloc_traits::max_size(__node_alloc_);
}
- _LIBCPP_HIDE_FROM_ABI static void __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void
+ __unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
- _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);
- _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(const __node_allocator& __a);
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __list_imp(__node_allocator&& __a) _NOEXCEPT;
# endif
- _LIBCPP_HIDE_FROM_ABI ~__list_imp();
- _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI ~__list_imp();
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __size_ == 0; }
- _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }
- _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__end_.__next_); }
- _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); }
- _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_as_link()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__end_.__next_); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
+ return const_iterator(__end_.__next_);
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_as_link()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT {
+ return const_iterator(__end_as_link());
+ }
- _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(__list_imp& __c)
# if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
# else
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<allocator_type>);
# endif
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c) {
__copy_assign_alloc(
__c, integral_constant<bool, __node_alloc_traits::propagate_on_container_copy_assignment::value>());
}
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c)
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<__node_allocator>::value) {
__move_assign_alloc(
@@ -547,7 +577,8 @@ protected:
}
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __node_pointer
+ __create_node(__base_pointer __prev, __base_pointer __next, _Args&&... __args) {
__allocation_guard<__node_allocator> __guard(__node_alloc_, 1);
// Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
// held inside the node, since we need to use the allocator's construct() method for that.
@@ -563,7 +594,7 @@ protected:
return __guard.__release_ptr();
}
- _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
// For the same reason as above, we use the allocator's destroy() method for the value_type,
// but not for the node itself.
__node_alloc_traits::destroy(__node_alloc_, std::addressof(__node->__get_value()));
@@ -572,54 +603,57 @@ protected:
}
private:
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp& __c, true_type) {
if (__node_alloc_ != __c.__node_alloc_)
clear();
__node_alloc_ = __c.__node_alloc_;
}
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __list_imp&, false_type) {}
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
__node_alloc_ = std::move(__c.__node_alloc_);
}
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__list_imp&, false_type) _NOEXCEPT {}
};
// Unlink nodes [__f, __l]
template <class _Tp, class _Alloc>
-inline void __list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
+__list_imp<_Tp, _Alloc>::__unlink_nodes(__base_pointer __f, __base_pointer __l) _NOEXCEPT {
__f->__prev_->__next_ = __l->__next_;
__l->__next_->__prev_ = __f->__prev_;
}
template <class _Tp, class _Alloc>
-inline __list_imp<_Tp, _Alloc>::__list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value)
: __size_(0) {}
template <class _Tp, class _Alloc>
-inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const allocator_type& __a)
: __size_(0), __node_alloc_(__node_allocator(__a)) {}
template <class _Tp, class _Alloc>
-inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a) : __size_(0), __node_alloc_(__a) {}
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(const __node_allocator& __a)
+ : __size_(0), __node_alloc_(__a) {}
# ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline __list_imp<_Tp, _Alloc>::__list_imp(__node_allocator&& __a) _NOEXCEPT
: __size_(0),
__node_alloc_(std::move(__a)) {}
# endif
template <class _Tp, class _Alloc>
-__list_imp<_Tp, _Alloc>::~__list_imp() {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 __list_imp<_Tp, _Alloc>::~__list_imp() {
clear();
}
template <class _Tp, class _Alloc>
-void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
if (!empty()) {
__base_pointer __f = __end_.__next_;
__base_pointer __l = __end_as_link();
@@ -634,7 +668,7 @@ void __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT {
}
template <class _Tp, class _Alloc>
-void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
# if _LIBCPP_STD_VER >= 14
_NOEXCEPT
# else
@@ -692,170 +726,204 @@ public:
typedef void __remove_return_type;
# endif
- _LIBCPP_HIDE_FROM_ABI list() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
- _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
- _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list()
+ _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(const allocator_type& __a) : __base(__a) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n);
# if _LIBCPP_STD_VER >= 14
- _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI explicit list(size_type __n, const allocator_type& __a);
# endif
- _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x);
template <__enable_if_t<__is_allocator<_Alloc>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI list(size_type __n, const value_type& __x, const allocator_type& __a) : __base(__a) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
+ list(size_type __n, const value_type& __x, const allocator_type& __a)
+ : __base(__a) {
for (; __n > 0; --__n)
push_back(__x);
}
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l);
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(_InpIter __f, _InpIter __l, const allocator_type& __a);
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<_Tp> _Range>
- _LIBCPP_HIDE_FROM_ABI list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
+ list(from_range_t, _Range&& __range, const allocator_type& __a = allocator_type())
: __base(__a) {
prepend_range(std::forward<_Range>(__range));
}
# endif
- _LIBCPP_HIDE_FROM_ABI list(const list& __c);
- _LIBCPP_HIDE_FROM_ABI list(const list& __c, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(const list& __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
+ list(const list& __c, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(const list& __c);
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);
- _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il, const allocator_type& __a);
-
- _LIBCPP_HIDE_FROM_ABI list(list&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
- _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a);
- _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) noexcept(
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(initializer_list<value_type> __il);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI
+ list(initializer_list<value_type> __il, const allocator_type& __a);
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c)
+ _NOEXCEPT_(is_nothrow_move_constructible<__node_allocator>::value);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list(list&& __c, const __type_identity_t<allocator_type>& __a);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(list&& __c) noexcept(
(__node_alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value) ||
allocator_traits<allocator_type>::is_always_equal::value);
- _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI list& operator=(initializer_list<value_type> __il) {
assign(__il.begin(), __il.end());
return *this;
}
- _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) { assign(__il.begin(), __il.end()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(initializer_list<value_type> __il) {
+ assign(__il.begin(), __il.end());
+ }
# endif // _LIBCPP_CXX03_LANG
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(_InpIter __f, _InpIter __l);
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<_Tp> _Range>
- _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign_range(_Range&& __range) {
__assign_with_sentinel(ranges::begin(__range), ranges::end(__range));
}
# endif
- _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __x);
- _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }
- [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __base::empty(); }
- _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return this->__size_; }
+ [[__nodiscard__]] _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT {
+ return __base::empty();
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
return std::min<size_type>(this->__node_alloc_max_size(), numeric_limits<difference_type >::max());
}
- _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }
- _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return __base::begin(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __base::begin(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __base::begin(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __base::end(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __base::end(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT {
+ return __base::begin();
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return __base::end(); }
- _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return const_reverse_iterator(end()); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return const_reverse_iterator(begin()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT {
+ return reverse_iterator(end());
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT {
+ return const_reverse_iterator(end());
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT {
+ return reverse_iterator(begin());
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT {
+ return const_reverse_iterator(begin());
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT {
+ return const_reverse_iterator(end());
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT {
+ return const_reverse_iterator(begin());
+ }
- _LIBCPP_HIDE_FROM_ABI reference front() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference front() {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
return __base::__end_.__next_->__as_node()->__get_value();
}
- _LIBCPP_HIDE_FROM_ABI const_reference front() const {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference front() const {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::front called on empty list");
return __base::__end_.__next_->__as_node()->__get_value();
}
- _LIBCPP_HIDE_FROM_ABI reference back() {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI reference back() {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
return __base::__end_.__prev_->__as_node()->__get_value();
}
- _LIBCPP_HIDE_FROM_ABI const_reference back() const {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI const_reference back() const {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::back called on empty list");
return __base::__end_.__prev_->__as_node()->__get_value();
}
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
- _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(value_type&& __x);
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<_Tp> _Range>
- _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void prepend_range(_Range&& __range) {
insert_range(begin(), std::forward<_Range>(__range));
}
template <_ContainerCompatibleRange<_Tp> _Range>
- _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void append_range(_Range&& __range) {
insert_range(end(), std::forward<_Range>(__range));
}
# endif
template <class... _Args>
+ _LIBCPP_CONSTEXPR_SINCE_CXX26
# if _LIBCPP_STD_VER >= 17
- _LIBCPP_HIDE_FROM_ABI reference emplace_front(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI reference
+ emplace_front(_Args&&... __args);
# else
- _LIBCPP_HIDE_FROM_ABI void emplace_front(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI void
+ emplace_front(_Args&&... __args);
# endif
template <class... _Args>
+ _LIBCPP_CONSTEXPR_SINCE_CXX26
# if _LIBCPP_STD_VER >= 17
- _LIBCPP_HIDE_FROM_ABI reference emplace_back(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI reference
+ emplace_back(_Args&&... __args);
# else
- _LIBCPP_HIDE_FROM_ABI void emplace_back(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI void
+ emplace_back(_Args&&... __args);
# endif
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator emplace(const_iterator __p, _Args&&... __args);
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __x);
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, initializer_list<value_type> __il) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
+ insert(const_iterator __p, initializer_list<value_type> __il) {
return insert(__p, __il.begin(), __il.end());
}
# endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);
- _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_front(const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void push_back(const value_type& __x);
# ifndef _LIBCPP_CXX03_LANG
template <class _Arg>
- _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __emplace_back(_Arg&& __arg) {
emplace_back(std::forward<_Arg>(__arg));
}
# else
_LIBCPP_HIDE_FROM_ABI void __emplace_back(value_type const& __arg) { push_back(__arg); }
# endif
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
+ insert(const_iterator __p, size_type __n, const value_type& __x);
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> = 0>
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, _InpIter __f, _InpIter __l);
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<_Tp> _Range>
- _LIBCPP_HIDE_FROM_ABI iterator insert_range(const_iterator __position, _Range&& __range) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
+ insert_range(const_iterator __position, _Range&& __range) {
return __insert_with_sentinel(__position, ranges::begin(__range), ranges::end(__range));
}
# endif
- _LIBCPP_HIDE_FROM_ABI void swap(list& __c)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void swap(list& __c)
# if _LIBCPP_STD_VER >= 14
_NOEXCEPT
# else
@@ -864,72 +932,80 @@ public:
{
__base::swap(__c);
}
- _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __base::clear(); }
- _LIBCPP_HIDE_FROM_ABI void pop_front();
- _LIBCPP_HIDE_FROM_ABI void pop_back();
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_front();
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void pop_back();
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
- _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
- _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void resize(size_type __n, const value_type& __x);
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c);
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) { splice(__p, __c, __i); }
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c) { splice(__p, __c); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list&& __c, const_iterator __i) {
+ splice(__p, __c, __i);
+ }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
+ splice(const_iterator __p, list&& __c, const_iterator __f, const_iterator __l) {
splice(__p, __c, __f, __l);
}
# endif
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);
- _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void splice(const_iterator __p, list& __c, const_iterator __i);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
+ splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
- _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove(const value_type& __x);
template <class _Pred>
- _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred);
- _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type remove_if(_Pred __pred);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique() { return unique(__equal_to()); }
template <class _BinaryPred>
- _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);
- _LIBCPP_HIDE_FROM_ABI void merge(list& __c);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __remove_return_type unique(_BinaryPred __binary_pred);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c);
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c) { merge(__c); }
template <class _Comp>
- _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list&& __c, _Comp __comp) {
merge(__c, __comp);
}
# endif
template <class _Comp>
- _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void merge(list& __c, _Comp __comp);
- _LIBCPP_HIDE_FROM_ABI void sort();
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort();
template <class _Comp>
- _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void sort(_Comp __comp);
- _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void reverse() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI bool __invariants() const;
private:
template <class _Iterator, class _Sentinel>
- _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __assign_with_sentinel(_Iterator __f, _Sentinel __l);
template <class _Iterator, class _Sentinel>
- _LIBCPP_HIDE_FROM_ABI iterator __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);
-
- _LIBCPP_HIDE_FROM_ABI static void __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);
- _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_front(__base_pointer __f, __base_pointer __l);
- _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);
- _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator
+ __insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l);
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI static void
+ __link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
+ __link_nodes_at_front(__base_pointer __f, __base_pointer __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __link_nodes_at_back(__base_pointer __f, __base_pointer __l);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI iterator __iterator(size_type __n);
// TODO: Make this _LIBCPP_HIDE_FROM_ABI
template <class _Comp>
- _LIBCPP_HIDDEN static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDDEN static iterator
+ __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp);
- _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type)
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value);
- _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __move_assign(list& __c, false_type);
};
# if _LIBCPP_STD_VER >= 17
@@ -955,7 +1031,8 @@ list(from_range_t, _Range&&, _Alloc = _Alloc()) -> list<ranges::range_value_t<_R
// Link in nodes [__f, __l] just prior to __p
template <class _Tp, class _Alloc>
-inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
+list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer __f, __base_pointer __l) {
__p->__prev_->__next_ = __f;
__f->__prev_ = __p->__prev_;
__p->__prev_ = __l;
@@ -964,7 +1041,8 @@ inline void list<_Tp, _Alloc>::__link_nodes(__base_pointer __p, __base_pointer _
// Link in nodes [__f, __l] at the front of the list
template <class _Tp, class _Alloc>
-inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
+list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_pointer __l) {
__f->__prev_ = __base::__end_as_link();
__l->__next_ = __base::__end_.__next_;
__l->__next_->__prev_ = __l;
@@ -973,7 +1051,8 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_front(__base_pointer __f, __base_
// Link in nodes [__f, __l] at the back of the list
template <class _Tp, class _Alloc>
-inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void
+list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_pointer __l) {
__l->__next_ = __base::__end_as_link();
__f->__prev_ = __base::__end_.__prev_;
__f->__prev_->__next_ = __f;
@@ -981,12 +1060,12 @@ inline void list<_Tp, _Alloc>::__link_nodes_at_back(__base_pointer __f, __base_p
}
template <class _Tp, class _Alloc>
-inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::__iterator(size_type __n) {
return __n <= this->__size_ / 2 ? std::next(begin(), __n) : std::prev(end(), this->__size_ - __n);
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(size_type __n) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n) {
for (; __n > 0; --__n)
# ifndef _LIBCPP_CXX03_LANG
emplace_back();
@@ -997,41 +1076,43 @@ list<_Tp, _Alloc>::list(size_type __n) {
# if _LIBCPP_STD_VER >= 14
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : __base(__a) {
for (; __n > 0; --__n)
emplace_back();
}
# endif
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) {
for (; __n > 0; --__n)
push_back(__x);
}
template <class _Tp, class _Alloc>
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
-list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l) {
for (; __f != __l; ++__f)
__emplace_back(*__f);
}
template <class _Tp, class _Alloc>
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
-list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a) : __base(__a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(_InpIter __f, _InpIter __l, const allocator_type& __a)
+ : __base(__a) {
for (; __f != __l; ++__f)
__emplace_back(*__f);
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(const list& __c)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c)
: __base(__node_alloc_traits::select_on_container_copy_construction(__c.__node_alloc_)) {
for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
push_back(*__i);
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>& __a)
+ : __base(__a) {
for (const_iterator __i = __c.begin(), __e = __c.end(); __i != __e; ++__i)
push_back(*__i);
}
@@ -1039,25 +1120,28 @@ list<_Tp, _Alloc>::list(const list& __c, const __type_identity_t<allocator_type>
# ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il, const allocator_type& __a)
+ : __base(__a) {
for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
push_back(*__i);
}
template <class _Tp, class _Alloc>
-list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 list<_Tp, _Alloc>::list(initializer_list<value_type> __il) {
for (typename initializer_list<value_type>::const_iterator __i = __il.begin(), __e = __il.end(); __i != __e; ++__i)
push_back(*__i);
}
template <class _Tp, class _Alloc>
-inline list<_Tp, _Alloc>::list(list&& __c) noexcept(is_nothrow_move_constructible<__node_allocator>::value)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c) noexcept(
+ is_nothrow_move_constructible<__node_allocator>::value)
: __base(std::move(__c.__node_alloc_)) {
splice(end(), __c);
}
template <class _Tp, class _Alloc>
-inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a) : __base(__a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_type>& __a)
+ : __base(__a) {
if (__a == __c.get_allocator())
splice(end(), __c);
else {
@@ -1067,7 +1151,7 @@ inline list<_Tp, _Alloc>::list(list&& __c, const __type_identity_t<allocator_typ
}
template <class _Tp, class _Alloc>
-inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
(__node_alloc_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value) ||
allocator_traits<allocator_type>::is_always_equal::value) {
@@ -1076,7 +1160,7 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(list&& __c) noexcept(
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
if (this->__node_alloc_ != __c.__node_alloc_) {
typedef move_iterator<iterator> _Ip;
assign(_Ip(__c.begin()), _Ip(__c.end()));
@@ -1085,8 +1169,8 @@ void list<_Tp, _Alloc>::__move_assign(list& __c, false_type) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::__move_assign(list& __c,
- true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void
+list<_Tp, _Alloc>::__move_assign(list& __c, true_type) noexcept(is_nothrow_move_assignable<__node_allocator>::value) {
clear();
__base::__move_assign_alloc(__c);
splice(end(), __c);
@@ -1095,7 +1179,7 @@ void list<_Tp, _Alloc>::__move_assign(list& __c,
# endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
if (this != std::addressof(__c)) {
__base::__copy_assign_alloc(__c);
assign(__c.begin(), __c.end());
@@ -1105,13 +1189,14 @@ inline list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list& __c) {
template <class _Tp, class _Alloc>
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
-void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l) {
__assign_with_sentinel(__f, __l);
}
template <class _Tp, class _Alloc>
template <class _Iterator, class _Sentinel>
-_LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void
+list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator __f, _Sentinel __l) {
iterator __i = begin();
iterator __e = end();
for (; __f != __l && __i != __e; ++__f, (void)++__i)
@@ -1123,7 +1208,7 @@ _LIBCPP_HIDE_FROM_ABI void list<_Tp, _Alloc>::__assign_with_sentinel(_Iterator _
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
iterator __i = begin();
iterator __e = end();
for (; __n > 0 && __i != __e; --__n, (void)++__i)
@@ -1135,12 +1220,13 @@ void list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x) {
}
template <class _Tp, class _Alloc>
-inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _Alloc list<_Tp, _Alloc>::get_allocator() const _NOEXCEPT {
return allocator_type(this->__node_alloc_);
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
__link_nodes(__p.__ptr_, __node->__as_link(), __node->__as_link());
++this->__size_;
@@ -1148,7 +1234,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& __x) {
iterator __r(__p.__ptr_);
if (__n > 0) {
@@ -1184,13 +1270,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
template <class _Tp, class _Alloc>
template <class _InpIter, __enable_if_t<__has_input_iterator_category<_InpIter>::value, int> >
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l) {
return __insert_with_sentinel(__p, __f, __l);
}
template <class _Tp, class _Alloc>
template <class _Iterator, class _Sentinel>
-_LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Sentinel __l) {
iterator __r(__p.__ptr_);
if (__f != __l) {
@@ -1225,7 +1312,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::push_front(const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(const value_type& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
__base_pointer __nl = __node->__as_link();
__link_nodes_at_front(__nl, __nl);
@@ -1233,7 +1320,7 @@ void list<_Tp, _Alloc>::push_front(const value_type& __x) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::push_back(const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(const value_type& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, __x);
__base_pointer __nl = __node->__as_link();
__link_nodes_at_back(__nl, __nl);
@@ -1243,7 +1330,7 @@ void list<_Tp, _Alloc>::push_back(const value_type& __x) {
# ifndef _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::push_front(value_type&& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_front(value_type&& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
__base_pointer __nl = __node->__as_link();
__link_nodes_at_front(__nl, __nl);
@@ -1251,7 +1338,7 @@ void list<_Tp, _Alloc>::push_front(value_type&& __x) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::push_back(value_type&& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::push_back(value_type&& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
__base_pointer __nl = __node->__as_link();
__link_nodes_at_back(__nl, __nl);
@@ -1260,12 +1347,13 @@ void list<_Tp, _Alloc>::push_back(value_type&& __x) {
template <class _Tp, class _Alloc>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX26
# if _LIBCPP_STD_VER >= 17
-typename list<_Tp, _Alloc>::reference
+ typename list<_Tp, _Alloc>::reference
# else
-void
+ void
# endif
-list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
+ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
__node_pointer __node =
this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
__base_pointer __nl = __node->__as_link();
@@ -1278,12 +1366,13 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) {
template <class _Tp, class _Alloc>
template <class... _Args>
+_LIBCPP_CONSTEXPR_SINCE_CXX26
# if _LIBCPP_STD_VER >= 17
-typename list<_Tp, _Alloc>::reference
+ typename list<_Tp, _Alloc>::reference
# else
-void
+ void
# endif
-list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
+ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
__node_pointer __node =
this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
__base_pointer __nl = __node->__as_link();
@@ -1296,7 +1385,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) {
template <class _Tp, class _Alloc>
template <class... _Args>
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) {
__node_pointer __node =
this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::forward<_Args>(__args)...);
__base_pointer __nl = __node->__as_link();
@@ -1306,7 +1396,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::emplace(const_iterator _
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) {
__node_pointer __node = this->__create_node(/* prev = */ nullptr, /* next = */ nullptr, std::move(__x));
__base_pointer __nl = __node->__as_link();
__link_nodes(__p.__ptr_, __nl, __nl);
@@ -1317,7 +1408,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::insert(const_iterator __
# endif // _LIBCPP_CXX03_LANG
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::pop_front() {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_front() {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_front() called with empty list");
__base_pointer __n = __base::__end_.__next_;
__base::__unlink_nodes(__n, __n);
@@ -1326,7 +1417,7 @@ void list<_Tp, _Alloc>::pop_front() {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::pop_back() {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::pop_back() {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "list::pop_back() called on an empty list");
__base_pointer __n = __base::__end_.__prev_;
__base::__unlink_nodes(__n, __n);
@@ -1335,7 +1426,7 @@ void list<_Tp, _Alloc>::pop_back() {
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p) {
_LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator");
__base_pointer __n = __p.__ptr_;
__base_pointer __r = __n->__next_;
@@ -1346,7 +1437,8 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __p
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
+list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) {
if (__f != __l) {
__base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_);
while (__f != __l) {
@@ -1360,7 +1452,7 @@ typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>::erase(const_iterator __f
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::resize(size_type __n) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n) {
if (__n < this->__size_)
erase(__iterator(__n), end());
else if (__n > this->__size_) {
@@ -1395,7 +1487,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
if (__n < this->__size_)
erase(__iterator(__n), end());
else if (__n > this->__size_) {
@@ -1431,7 +1523,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
_LIBCPP_ASSERT_VALID_INPUT_RANGE(
this != std::addressof(__c), "list::splice(iterator, list) called with this == &list");
if (!__c.empty()) {
@@ -1445,7 +1537,7 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) {
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) {
if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) {
__base_pointer __f = __i.__ptr_;
__base::__unlink_nodes(__f, __f);
@@ -1456,7 +1548,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void
+list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l) {
if (__f != __l) {
__base_pointer __first = __f.__ptr_;
--__l;
@@ -1472,7 +1565,8 @@ void list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f
}
template <class _Tp, class _Alloc>
-typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const value_type& __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::remove(const value_type& __x) {
list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (const_iterator __i = begin(), __e = end(); __i != __e;) {
if (*__i == __x) {
@@ -1492,7 +1586,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove(const
template <class _Tp, class _Alloc>
template <class _Pred>
-typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_Pred __pred) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::remove_if(_Pred __pred) {
list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (iterator __i = begin(), __e = end(); __i != __e;) {
if (__pred(*__i)) {
@@ -1512,7 +1607,8 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::remove_if(_P
template <class _Tp, class _Alloc>
template <class _BinaryPred>
-typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::__remove_return_type
+list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred) {
list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (iterator __i = begin(), __e = end(); __i != __e;) {
iterator __j = std::next(__i);
@@ -1528,13 +1624,13 @@ typename list<_Tp, _Alloc>::__remove_return_type list<_Tp, _Alloc>::unique(_Bina
}
template <class _Tp, class _Alloc>
-inline void list<_Tp, _Alloc>::merge(list& __c) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::merge(list& __c) {
merge(__c, __less<>());
}
template <class _Tp, class _Alloc>
template <class _Comp>
-void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
if (this != std::addressof(__c)) {
iterator __f1 = begin();
iterator __e1 = end();
@@ -1563,19 +1659,19 @@ void list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) {
}
template <class _Tp, class _Alloc>
-inline void list<_Tp, _Alloc>::sort() {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort() {
sort(__less<>());
}
template <class _Tp, class _Alloc>
template <class _Comp>
-inline void list<_Tp, _Alloc>::sort(_Comp __comp) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline void list<_Tp, _Alloc>::sort(_Comp __comp) {
__sort(begin(), end(), this->__size_, __comp);
}
template <class _Tp, class _Alloc>
template <class _Comp>
-typename list<_Tp, _Alloc>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp) {
switch (__n) {
case 0:
@@ -1629,7 +1725,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __
}
template <class _Tp, class _Alloc>
-void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
if (this->__size_ > 1) {
iterator __e = end();
for (iterator __i = begin(); __i.__ptr_ != __e.__ptr_;) {
@@ -1641,46 +1737,52 @@ void list<_Tp, _Alloc>::reverse() _NOEXCEPT {
}
template <class _Tp, class _Alloc>
-bool list<_Tp, _Alloc>::__invariants() const {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 bool list<_Tp, _Alloc>::__invariants() const {
return size() == std::distance(begin(), end());
}
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator==(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
}
# if _LIBCPP_STD_VER <= 17
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator<(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return !(__x == __y);
}
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator>(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return __y < __x;
}
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator>=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return !(__x < __y);
}
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI bool
+operator<=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y) {
return !(__y < __x);
}
# else // _LIBCPP_STD_VER <= 17
template <class _Tp, class _Allocator>
-_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
+_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Tp>
operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y) {
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
}
@@ -1688,20 +1790,20 @@ operator<=>(const list<_Tp, _Allocator>& __x, const list<_Tp, _Allocator>& __y)
# endif // _LIBCPP_STD_VER <= 17
template <class _Tp, class _Alloc>
-inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI void swap(list<_Tp, _Alloc>& __x, list<_Tp, _Alloc>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
__x.swap(__y);
}
# if _LIBCPP_STD_VER >= 20
template <class _Tp, class _Allocator, class _Predicate>
-inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
erase_if(list<_Tp, _Allocator>& __c, _Predicate __pred) {
return __c.remove_if(__pred);
}
template <class _Tp, class _Allocator, class _Up>
-inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 inline _LIBCPP_HIDE_FROM_ABI typename list<_Tp, _Allocator>::size_type
erase(list<_Tp, _Allocator>& __c, const _Up& __v) {
return std::erase_if(__c, [&](const auto& __elem) -> bool { return __elem == __v; });
}
diff --git a/libcxx/include/version b/libcxx/include/version
index 63ead9fd5d29d..12ce89b77fa79 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -68,6 +68,7 @@ __cpp_lib_constexpr_complex 201711L <complex>
__cpp_lib_constexpr_dynamic_alloc 201907L <memory>
__cpp_lib_constexpr_functional 201907L <functional>
__cpp_lib_constexpr_iterator 201811L <iterator>
+__cpp_lib_constexpr_list 202502L <list>
__cpp_lib_constexpr_memory 202202L <memory>
201811L // C++20
__cpp_lib_constexpr_new 202406L <new>
@@ -536,6 +537,7 @@ __cpp_lib_void_t 201411L <type_traits>
# undef __cpp_lib_bind_front
# define __cpp_lib_bind_front 202306L
# define __cpp_lib_bitset 202306L
+# define __cpp_lib_constexpr_list 202502L
# if !defined(_LIBCPP_ABI_VCRUNTIME)
# define __cpp_lib_constexpr_new 202406L
# endif
diff --git a/libcxx/test/std/containers/sequences/list/compare.pass.cpp b/libcxx/test/std/containers/sequences/list/compare.pass.cpp
index ce00f57733bf9..9705fd9161987 100644
--- a/libcxx/test/std/containers/sequences/list/compare.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/compare.pass.cpp
@@ -10,34 +10,34 @@
// template< class T, class Alloc >
// bool operator==( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator!=( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator<( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator<=( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator>( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
// template< class T, class Alloc >
// bool operator>=( const std::list<T,Alloc>& lhs,
-// const std::list<T,Alloc>& rhs );
+// const std::list<T,Alloc>& rhs ); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_comparisons.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
const std::list<int> l1, l2;
assert(testComparisons(l1, l2, true, false));
@@ -113,5 +113,15 @@ int main(int, char**) {
const std::list<LessAndEqComp> l2(items2, items2 + 2);
assert(testComparisons(l1, l2, false, false));
}
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp b/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
index 059fba3c26268..7a23a653c0aa8 100644
--- a/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/compare.three_way.pass.cpp
@@ -11,7 +11,7 @@
// template <class T, class Allocator> constexpr
// synth-three-way-result<T>
-// operator<=>(const list<T, Allocator>& x, const list<T, Allocator>& y);
+// operator<=>(const list<T, Allocator>& x, const list<T, Allocator>& y); // constexpr since C++26
#include <list>
#include <cassert>
@@ -20,6 +20,8 @@
int main(int, char**) {
assert(test_sequence_container_spaceship<std::list>());
- // `std::list` is not constexpr, so no `static_assert` test here.
+#if TEST_STD_VER >= 26
+ static_assert(test_sequence_container_spaceship<std::list>());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/get_allocator.pass.cpp b/libcxx/test/std/containers/sequences/list/get_allocator.pass.cpp
index f1002f2ca8113..9d724673d31e8 100644
--- a/libcxx/test/std/containers/sequences/list/get_allocator.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/get_allocator.pass.cpp
@@ -10,7 +10,7 @@
// class list
-// allocator_type get_allocator() const
+// allocator_type get_allocator() const // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::allocator<int> alloc;
const std::list<int> l(alloc);
@@ -30,5 +30,14 @@ int main(int, char**) {
assert(l.get_allocator() == alloc);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/incomplete_type.pass.cpp b/libcxx/test/std/containers/sequences/list/incomplete_type.pass.cpp
index 1802e53ecf387..ac8a76097d0ab 100644
--- a/libcxx/test/std/containers/sequences/list/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/incomplete_type.pass.cpp
@@ -12,6 +12,7 @@
// type.
#include <list>
+#include <cassert>
#include "test_macros.h"
@@ -23,8 +24,18 @@ struct A {
std::list<A>::const_reverse_iterator crit;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
A a;
+ (void)a;
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/iterators.pass.cpp b/libcxx/test/std/containers/sequences/list/iterators.pass.cpp
index deaae31f2d27c..b41a1899f2ff1 100644
--- a/libcxx/test/std/containers/sequences/list/iterators.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/iterators.pass.cpp
@@ -8,12 +8,12 @@
// <list>
-// iterator begin();
-// iterator end();
-// const_iterator begin() const;
-// const_iterator end() const;
-// const_iterator cbegin() const;
-// const_iterator cend() const;
+// iterator begin(); // constexpr since C++26
+// iterator end(); // constexpr since C++26
+// const_iterator begin() const; // constexpr since C++26
+// const_iterator end() const; // constexpr since C++26
+// const_iterator cbegin() const; // constexpr since C++26
+// const_iterator cend() const; // constexpr since C++26
#include <list>
#include <cassert>
@@ -27,7 +27,7 @@ struct A {
int second;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int T;
typedef std::list<T> C;
@@ -74,6 +74,8 @@ int main(int, char**) {
typedef std::list<T> C;
C::iterator i;
C::const_iterator j;
+ (void)i;
+ (void)j;
}
#if TEST_STD_VER >= 11
{
@@ -122,6 +124,8 @@ int main(int, char**) {
typedef std::list<T, min_allocator<T>> C;
C::iterator i;
C::const_iterator j;
+ (void)i;
+ (void)j;
}
{
typedef A T;
@@ -150,5 +154,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
index 50ca23ff9c56c..f368d8e700bb6 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/empty.pass.cpp
@@ -10,7 +10,7 @@
// class list
-// bool empty() const noexcept;
+// bool empty() const noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<int> C;
C c;
@@ -42,5 +42,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp
index 74c2ccfb14421..1f956b33e4822 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/max_size.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// size_type max_size() const noexcept
+// size_type max_size() const noexcept // constexpr since C++26
#include <cassert>
#include <limits>
@@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "test_macros.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef limited_allocator<int, 10> A;
typedef std::list<int, A> C;
@@ -42,5 +42,14 @@ int main(int, char**) {
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
index 754d931646cc6..32049b22881b9 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
@@ -8,15 +8,17 @@
// <list>
-// void resize(size_type sz);
+// void resize(size_type sz); // constexpr since C++26
#include <list>
#include <cassert>
+#include <type_traits>
+
#include "test_macros.h"
#include "DefaultOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(5, 2);
l.resize(2);
@@ -33,17 +35,31 @@ int main(int, char**) {
assert(l.back() == 0);
}
#if TEST_STD_VER >= 11
- {
- std::list<DefaultOnly> l(10);
- l.resize(5);
- assert(l.size() == 5);
- assert(std::distance(l.begin(), l.end()) == 5);
- }
- {
- std::list<DefaultOnly> l(10);
- l.resize(20);
- assert(l.size() == 20);
- assert(std::distance(l.begin(), l.end()) == 20);
+ if (!std::is_constant_evaluated()) {
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
}
{
std::list<int, min_allocator<int>> l(5, 2);
@@ -60,18 +76,15 @@ int main(int, char**) {
assert(l.front() == 2);
assert(l.back() == 0);
}
- {
- std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
- l.resize(5);
- assert(l.size() == 5);
- assert(std::distance(l.begin(), l.end()) == 5);
- }
- {
- std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
- l.resize(20);
- assert(l.size() == 20);
- assert(std::distance(l.begin(), l.end()) == 20);
- }
+#endif
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
#endif
return 0;
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
index 95fccddeca540..a93ec224bd6da 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void resize(size_type sz, const value_type& x);
+// void resize(size_type sz, const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<double> l(5, 2);
l.resize(2, 3.5);
@@ -50,5 +50,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp
index 930331205a9a5..8aecfcaea0270 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/size.pass.cpp
@@ -10,7 +10,7 @@
// class list
-// size_type size() const noexcept;
+// size_type size() const noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<int> C;
C c;
@@ -58,5 +58,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
index ca468d870998e..912975d55e1d7 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// list& operator=(const list& c);
+// list& operator=(const list& c); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@@ -41,5 +41,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
index d4c1120df6226..07b25f189a111 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// void assign(initializer_list<value_type> il);
+// void assign(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d;
d.assign({3, 4, 5, 6});
@@ -40,5 +40,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
index 87faaaac2b210..aa199b05ed45c 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// list& operator=(list&& c);
+// list& operator=(list&& c); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@@ -79,5 +79,14 @@ int main(int, char**) {
assert(it == l2.begin()); // Iterators remain valid
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp
index de52da0fefabf..a3e510d4d6ebf 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// list(const list& c);
+// list(const list& c); // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3, 2);
std::list<int> l2 = l;
@@ -50,5 +50,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
index 0d6c6f431f09d..5da17a9c9b592 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// list(const list& c, const allocator_type& a);
+// list(const list& c, const allocator_type& a); // constexpr since C++26
#include <list>
#include <cassert>
@@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
@@ -39,5 +39,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp
index 0cfd8f1e9c594..1256433659c61 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// explicit list(const Alloc& = Alloc());
+// explicit list(const Alloc& = Alloc()); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l;
assert(l.size() == 0);
@@ -65,5 +65,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
index e31a58d7b9a5c..3a78d0e0e0d5e 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// explicit list(const Alloc& = Alloc());
+// explicit list(const Alloc& = Alloc()); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l;
assert(l.size() == 0);
@@ -45,5 +45,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/from_range.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/from_range.pass.cpp
index cc5ed5729b57b..60a4764725679 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/from_range.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/from_range.pass.cpp
@@ -9,14 +9,15 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
-// list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23
+// list(from_range_t, R&& rg, const Allocator& = Allocator()); // C++23; constexpr since C++26
#include <list>
+#include <type_traits>
#include "../../from_range_sequence_containers.h"
#include "test_macros.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
for_all_iterators_and_allocators<int>([]<class Iter, class Sent, class Alloc>() {
test_sequence_container<std::list, int, Iter, Sent, Alloc>([](const auto&) {
// No additional validation to do.
@@ -26,8 +27,19 @@ int main(int, char**) {
static_assert(test_constraints<std::list, int, double>());
- test_exception_safety_throwing_copy<std::list>();
- test_exception_safety_throwing_allocator<std::list, int>();
+ if (!std::is_constant_evaluated()) {
+ test_exception_safety_throwing_copy<std::list>();
+ test_exception_safety_throwing_allocator<std::list, int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
index 3ba90d1337e94..9e3a71ed3bd1c 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// list(initializer_list<value_type> il);
+// list(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d = {3, 4, 5, 6};
assert(d.size() == 4);
@@ -38,5 +38,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
index e4779eb5a6401..1b6b1e19c6eba 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type()); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
assert(d.get_allocator() == test_allocator<int>(3));
@@ -41,5 +41,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
index c99069f92f51d..e24d123c37318 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
@@ -9,10 +9,11 @@
// <list>
// template <class InputIterator>
-// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+// list(InputIterator first, InputIterator last, const Allocator& = Allocator()); // constexpr since C++26
#include <list>
#include <cassert>
+
#include "test_macros.h"
#include "test_iterators.h"
#include "test_allocator.h"
@@ -22,7 +23,7 @@
# include "container_test_types.h"
#endif
-void basic_test() {
+TEST_CONSTEXPR_CXX26 void basic_test() {
{
int a[] = {0, 1, 2, 3};
std::list<int> l(
@@ -81,7 +82,7 @@ void basic_test() {
#endif
}
-void test_emplacable_concept() {
+TEST_CONSTEXPR_CXX26 void test_emplacable_concept() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@@ -126,7 +127,7 @@ void test_emplacable_concept() {
#endif
}
-void test_emplacable_concept_with_alloc() {
+TEST_CONSTEXPR_CXX26 void test_emplacable_concept_with_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@@ -173,7 +174,7 @@ void test_emplacable_concept_with_alloc() {
#endif
}
-void test_ctor_under_alloc() {
+TEST_CONSTEXPR_CXX26 void test_ctor_under_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@@ -204,7 +205,7 @@ void test_ctor_under_alloc() {
#endif
}
-void test_ctor_under_alloc_with_alloc() {
+TEST_CONSTEXPR_CXX26 void test_ctor_under_alloc_with_alloc() {
#if TEST_STD_VER >= 11
int arr1[] = {42};
int arr2[] = {1, 101, 42};
@@ -239,12 +240,24 @@ void test_ctor_under_alloc_with_alloc() {
#endif
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
basic_test();
test_emplacable_concept();
test_emplacable_concept_with_alloc();
- test_ctor_under_alloc();
- test_ctor_under_alloc_with_alloc();
+
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ test_ctor_under_alloc();
+ test_ctor_under_alloc_with_alloc();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp
index 6703390f10b94..cae2886cf08b8 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// list(list&& c);
+// list(list&& c); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@@ -63,5 +63,14 @@ int main(int, char**) {
assert(it == l2.begin()); // Iterators remain valid
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
index f6a1f2c33a63a..dee0282c99780 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// list(list&& c, const allocator_type& a);
+// list(list&& c, const allocator_type& a); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
@@ -69,5 +69,14 @@ int main(int, char**) {
assert(l2.get_allocator() == min_allocator<MoveOnly>());
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
index a9ab30b82640c..d7679931ee71f 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -10,14 +10,14 @@
// <list>
-// list& operator=(initializer_list<value_type> il);
+// list& operator=(initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d;
d = {3, 4, 5, 6};
@@ -39,5 +39,14 @@ int main(int, char**) {
assert(*i++ == 6);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
index 937a86a27e058..f9c3b8c2a96c4 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -8,18 +8,20 @@
// <list>
-// explicit list(size_type n);
+// explicit list(size_type n); // constexpr since C++26
#include <list>
#include <cassert>
#include <cstddef>
+#include <type_traits>
+
#include "test_macros.h"
#include "DefaultOnly.h"
#include "test_allocator.h"
#include "min_allocator.h"
template <class T, class Allocator>
-void test3(unsigned n, Allocator const& alloc = Allocator()) {
+TEST_CONSTEXPR_CXX26 void test1(unsigned n, Allocator const& alloc = Allocator()) {
#if TEST_STD_VER > 11
typedef std::list<T, Allocator> C;
{
@@ -34,7 +36,7 @@ void test3(unsigned n, Allocator const& alloc = Allocator()) {
#endif
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3);
assert(l.size() == 3);
@@ -70,15 +72,10 @@ int main(int, char**) {
assert(*i == 0);
++i;
assert(*i == 0);
- test3<int, min_allocator<int>>(3);
+ test1<int, min_allocator<int>>(3);
}
#endif
#if TEST_STD_VER >= 11
- {
- std::list<DefaultOnly> l(3);
- assert(l.size() == 3);
- assert(std::distance(l.begin(), l.end()) == 3);
- }
{
std::list<int, min_allocator<int>> l(3);
assert(l.size() == 3);
@@ -90,12 +87,29 @@ int main(int, char**) {
++i;
assert(*i == 0);
}
- {
- std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
- assert(l.size() == 3);
- assert(std::distance(l.begin(), l.end()) == 3);
+
+ if (!std::is_constant_evaluated()) {
+ {
+ std::list<DefaultOnly> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
index ff7982ce147d5..42700c3ed6582 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// list(size_type n, const T& value, const Allocator& = Allocator());
+// list(size_type n, const T& value, const Allocator& = Allocator()); // constexpr since C++26
#include <list>
#include <cassert>
@@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> l(3, 2);
assert(l.size() == 3);
@@ -77,5 +77,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.erasure/erase.pass.cpp b/libcxx/test/std/containers/sequences/list/list.erasure/erase.pass.cpp
index 77f9f89560375..babd4b2758e6a 100644
--- a/libcxx/test/std/containers/sequences/list/list.erasure/erase.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.erasure/erase.pass.cpp
@@ -11,7 +11,7 @@
// template <class T, class Allocator, class U>
// typename list<T, Allocator>::size_type
-// erase(list<T, Allocator>& c, const U& value);
+// erase(list<T, Allocator>& c, const U& value); // constexpr since C++26
#include <list>
#include <optional>
@@ -21,14 +21,14 @@
#include "min_allocator.h"
template <class S, class U>
-void test0(S s, U val, S expected, std::size_t expected_erased_count) {
+TEST_CONSTEXPR_CXX26 void test0(S s, U val, S expected, std::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_CXX26 void test1() {
test0(S(), 1, S(), 0);
test0(S({1}), 1, S(), 1);
@@ -62,13 +62,22 @@ void test() {
test0(S({1, 2, 1}), opt(3), S({1, 2, 1}), 0);
}
-int main(int, char**) {
- test<std::list<int>>();
- test<std::list<int, min_allocator<int>>>();
- test<std::list<int, test_allocator<int>>>();
+TEST_CONSTEXPR_CXX26 bool test() {
+ test1<std::list<int>>();
+ test1<std::list<int, min_allocator<int>>>();
+ test1<std::list<int, test_allocator<int>>>();
+
+ test1<std::list<long>>();
+ test1<std::list<double>>();
- test<std::list<long>>();
- test<std::list<double>>();
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/sequences/list/list.erasure/erase_if.pass.cpp
index 5352a2f454f80..e396330bc68c4 100644
--- a/libcxx/test/std/containers/sequences/list/list.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.erasure/erase_if.pass.cpp
@@ -11,7 +11,7 @@
// template <class T, class Allocator, class Predicate>
// typename list<T, Allocator>::size_type
-// erase_if(list<T, Allocator>& c, Predicate pred);
+// erase_if(list<T, Allocator>& c, Predicate pred); // constexpr since C++26
#include <list>
@@ -20,14 +20,14 @@
#include "min_allocator.h"
template <class S, class Pred>
-void test0(S s, Pred p, S expected, std::size_t expected_erased_count) {
+TEST_CONSTEXPR_CXX26 void test0(S s, Pred p, S expected, std::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_CXX26 void test1() {
auto is1 = [](auto v) { return v == 1; };
auto is2 = [](auto v) { return v == 2; };
auto is3 = [](auto v) { return v == 3; };
@@ -64,13 +64,22 @@ void test() {
test0(S({1, 2, 3}), False, S({1, 2, 3}), 0);
}
-int main(int, char**) {
- test<std::list<int>>();
- test<std::list<int, min_allocator<int>>>();
- test<std::list<int, test_allocator<int>>>();
+TEST_CONSTEXPR_CXX26 bool test() {
+ test1<std::list<int>>();
+ test1<std::list<int, min_allocator<int>>>();
+ test1<std::list<int, test_allocator<int>>>();
+
+ test1<std::list<long>>();
+ test1<std::list<double>>();
- test<std::list<long>>();
- test<std::list<double>>();
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/append_range.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/append_range.pass.cpp
index 46a99cb548447..66b72415f3b26 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/append_range.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/append_range.pass.cpp
@@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
-// constexpr void append_range(R&& rg); // C++23
+// constexpr void append_range(R&& rg); // C++23; constexpr since C++26
#include <list>
+#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - appending move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_append_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_append_range_move_only<std::list>();
- test_append_range_exception_safety_throwing_copy<std::list>();
- test_append_range_exception_safety_throwing_allocator<std::list, int>();
+ if (!std::is_constant_evaluated()) {
+ test_append_range_exception_safety_throwing_copy<std::list>();
+ test_append_range_exception_safety_throwing_allocator<std::list, int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/assign_range.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/assign_range.pass.cpp
index d745786b6815d..92a835e1c91bd 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/assign_range.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/assign_range.pass.cpp
@@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
-// constexpr void assign_range(R&& rg); // C++23
+// constexpr void assign_range(R&& rg); // C++23; constexpr since C++26
#include <list>
+#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - assigning move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_assign_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_assign_range_move_only<std::list>();
- test_assign_range_exception_safety_throwing_copy<std::list>();
- test_assign_range_exception_safety_throwing_allocator<std::list, int>();
+ if (!std::is_constant_evaluated()) {
+ test_assign_range_exception_safety_throwing_copy<std::list>();
+ test_assign_range_exception_safety_throwing_allocator<std::list, int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
index 5931fd62d037c..0b38ae05bd684 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void clear() noexcept;
+// void clear() noexcept; // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
index 2f83aa0d317b5..9bd7a151d20e1 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// template <class... Args> void emplace(const_iterator p, Args&&... args);
+// template <class... Args> void emplace(const_iterator p, Args&&... args); // constexpr since C++26
#include <list>
#include <cassert>
@@ -26,13 +26,13 @@ class A {
A& operator=(const A&);
public:
- A(int i, double d) : i_(i), d_(d) {}
+ TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
- int geti() const { return i_; }
- double getd() const { return d_; }
+ TEST_CONSTEXPR int geti() const { return i_; }
+ TEST_CONSTEXPR double getd() const { return d_; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
c.emplace(c.cbegin(), 2, 3.5);
@@ -60,5 +60,14 @@ int main(int, char**) {
assert(c.back().getd() == 4.5);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
index 900f8b83d3e69..5f84c4c7c05ab 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// template <class... Args> reference emplace_back(Args&&... args);
+// template <class... Args> reference emplace_back(Args&&... args); // constexpr since C++26
// return type is 'reference' in C++17; 'void' before
#include <list>
@@ -27,13 +27,13 @@ class A {
A& operator=(const A&);
public:
- A(int i, double d) : i_(i), d_(d) {}
+ TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
- int geti() const { return i_; }
- double getd() const { return d_; }
+ TEST_CONSTEXPR int geti() const { return i_; }
+ TEST_CONSTEXPR double getd() const { return d_; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
#if TEST_STD_VER > 14
@@ -83,5 +83,14 @@ int main(int, char**) {
assert(c.back().getd() == 4.5);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
index 665f5077bd429..95474b52dbd00 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// template <class... Args> reference emplace_front(Args&&... args);
+// template <class... Args> reference emplace_front(Args&&... args); // constexpr since C++26
// return type is 'reference' in C++17; 'void' before
#include <list>
@@ -27,13 +27,13 @@ class A {
A& operator=(const A&);
public:
- A(int i, double d) : i_(i), d_(d) {}
+ TEST_CONSTEXPR_CXX20 A(int i, double d) : i_(i), d_(d) {}
- int geti() const { return i_; }
- double getd() const { return d_; }
+ TEST_CONSTEXPR int geti() const { return i_; }
+ TEST_CONSTEXPR double getd() const { return d_; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<A> c;
#if TEST_STD_VER > 14
@@ -84,5 +84,14 @@ int main(int, char**) {
assert(c.back().getd() == 3.5);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
index ba139b4367d73..79dae11a82631 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// iterator erase(const_iterator position);
+// iterator erase(const_iterator position); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3};
std::list<int> l1(a1, a1 + 3);
@@ -62,5 +62,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
index cc8d537032d04..fa6f8139ff756 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// iterator erase(const_iterator first, const_iterator last);
+// iterator erase(const_iterator first, const_iterator last); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
{
std::list<int> l1(a1, a1 + 3);
@@ -81,5 +81,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
index 8bd01c940d958..4475d27a7e737 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// iterator insert(const_iterator p, initializer_list<value_type> il);
+// iterator insert(const_iterator p, initializer_list<value_type> il); // constexpr since C++26
#include <list>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> d(10, 1);
std::list<int>::iterator i = d.insert(std::next(d.cbegin(), 2), {3, 4, 5, 6});
@@ -62,5 +62,14 @@ int main(int, char**) {
assert(*i++ == 1);
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
index bab125ca62094..27db218511aaf 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// template <InputIterator Iter>
-// iterator insert(const_iterator position, Iter first, Iter last);
+// iterator insert(const_iterator position, Iter first, Iter last); // constexpr since C++26
#include <list>
#include <cstdlib>
@@ -21,7 +21,7 @@
#include "count_new.h"
template <class List>
-void test() {
+TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
List l1;
typename List::iterator i = l1.insert(l1.begin(), a1, a1 + 3);
@@ -53,36 +53,47 @@ void test() {
assert(*i == 3);
#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
- globalMemCounter.throw_after = 2;
- int save_count = globalMemCounter.outstanding_new;
- try {
- i = l1.insert(i, a2, a2 + 3);
- assert(false);
- } catch (...) {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ globalMemCounter.throw_after = 2;
+ int save_count = globalMemCounter.outstanding_new;
+ try {
+ i = l1.insert(i, a2, a2 + 3);
+ assert(false);
+ } catch (...) {
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
+ assert(l1.size() == 6);
+ assert(std::distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
}
- assert(globalMemCounter.checkOutstandingNewEq(save_count));
- assert(l1.size() == 6);
- assert(std::distance(l1.begin(), l1.end()) == 6);
- i = l1.begin();
- assert(*i == 1);
- ++i;
- assert(*i == 2);
- ++i;
- assert(*i == 4);
- ++i;
- assert(*i == 5);
- ++i;
- assert(*i == 6);
- ++i;
- assert(*i == 3);
#endif
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
index 8bb513208eb7f..7d7b2f158a602 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// iterator insert(const_iterator position, value_type&& x);
+// iterator insert(const_iterator position, value_type&& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.insert(l1.cend(), MoveOnly(1));
@@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(1));
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
index 32ee7a73406dc..1056d997f9d85 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// iterator insert(const_iterator position, size_type n, const value_type& x);
+// iterator insert(const_iterator position, size_type n, const value_type& x); // constexpr since C++26
// UNSUPPORTED: sanitizer-new-delete
@@ -21,7 +21,7 @@
#include "test_macros.h"
template <class List>
-void test() {
+TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
List l1(a1, a1 + 3);
@@ -29,23 +29,34 @@ void test() {
assert(i == std::next(l1.begin()));
assert(l1 == List(a2, a2 + 8));
#ifndef TEST_HAS_NO_EXCEPTIONS
- globalMemCounter.throw_after = 4;
- int save_count = globalMemCounter.outstanding_new;
- try {
- i = l1.insert(i, 5, 5);
- assert(false);
- } catch (...) {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ globalMemCounter.throw_after = 4;
+ int save_count = globalMemCounter.outstanding_new;
+ try {
+ i = l1.insert(i, 5, 5);
+ assert(false);
+ } catch (...) {
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
+ assert(l1 == List(a2, a2 + 8));
}
- assert(globalMemCounter.checkOutstandingNewEq(save_count));
- assert(l1 == List(a2, a2 + 8));
#endif
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
index 129fe05cb39d2..615bb5bb2b42e 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// iterator insert(const_iterator position, const value_type& x);
+// iterator insert(const_iterator position, const value_type& x); // constexpr since C++26
#include <list>
#include <cstdlib>
@@ -19,7 +19,7 @@
#include "count_new.h"
template <class List>
-void test() {
+TEST_CONSTEXPR_CXX26 void test() {
int a1[] = {1, 2, 3};
int a2[] = {1, 4, 2, 3};
List l1(a1, a1 + 3);
@@ -30,23 +30,34 @@ void test() {
assert(l1 == List(a2, a2 + 4));
#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT)
- globalMemCounter.throw_after = 0;
- int save_count = globalMemCounter.outstanding_new;
- try {
- i = l1.insert(i, 5);
- assert(false);
- } catch (...) {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ globalMemCounter.throw_after = 0;
+ int save_count = globalMemCounter.outstanding_new;
+ try {
+ i = l1.insert(i, 5);
+ assert(false);
+ } catch (...) {
+ }
+ assert(globalMemCounter.checkOutstandingNewEq(save_count));
+ assert(l1 == List(a2, a2 + 4));
}
- assert(globalMemCounter.checkOutstandingNewEq(save_count));
- assert(l1 == List(a2, a2 + 4));
#endif
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test<std::list<int> >();
#if TEST_STD_VER >= 11
test<std::list<int, min_allocator<int>>>();
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_range.pass.cpp
index eb3937eb8f9e7..370d7ab1aee64 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_range.pass.cpp
@@ -6,12 +6,16 @@
//
//===----------------------------------------------------------------------===//
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=20000000
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-ops-limit): -fconstexpr-ops-limit=80000000
+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
-// constexpr iterator insert_range(const_iterator position, R&& rg); // C++23
+// constexpr iterator insert_range(const_iterator position, R&& rg); // C++23; constexpr since C++26
#include <list>
+#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@@ -21,7 +25,7 @@
// {empty/one-element/full} container at the {beginning/middle/end});
// - inserting move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_insert_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@@ -31,8 +35,19 @@ int main(int, char**) {
});
test_sequence_insert_range_move_only<std::list>();
- test_insert_range_exception_safety_throwing_copy<std::list>();
- test_insert_range_exception_safety_throwing_allocator<std::list, int>();
+ if (!std::is_constant_evaluated()) {
+ test_insert_range_exception_safety_throwing_copy<std::list>();
+ test_insert_range_exception_safety_throwing_allocator<std::list, int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
index aaa225b147767..5bbac428d8d5e 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void pop_back();
+// void pop_back(); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@@ -40,5 +40,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
index 33b8ff35c524c..74b6a1cc319b7 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void pop_front();
+// void pop_front(); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a[] = {1, 2, 3};
std::list<int> c(a, a + 3);
@@ -40,5 +40,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/prepend_range.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/prepend_range.pass.cpp
index d5e4d4fabb761..b978166564583 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/prepend_range.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/prepend_range.pass.cpp
@@ -9,9 +9,10 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// template<container-compatible-range<T> R>
-// constexpr void prepend_range(R&& rg); // C++23
+// constexpr void prepend_range(R&& rg); // C++23; constexpr since C++26
#include <list>
+#include <type_traits>
#include "../../insert_range_sequence_containers.h"
#include "test_macros.h"
@@ -21,7 +22,7 @@
// {empty/one-element/full} container);
// - prepending move-only elements;
// - an exception is thrown when copying the elements or when allocating new elements.
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
static_assert(test_constraints_prepend_range<std::list, int, double>());
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
@@ -31,8 +32,19 @@ int main(int, char**) {
});
test_sequence_prepend_range_move_only<std::list>();
- test_prepend_range_exception_safety_throwing_copy<std::list>();
- test_prepend_range_exception_safety_throwing_allocator<std::list, int>();
+ if (!std::is_constant_evaluated()) {
+ test_prepend_range_exception_safety_throwing_copy<std::list>();
+ test_prepend_range_exception_safety_throwing_allocator<std::list, int>();
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
index 582f4a200ac26..3ac9a60e7901c 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void push_back(const value_type& x);
+// void push_back(const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> c;
for (int i = 0; i < 5; ++i)
@@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
index 6a31d81d694f3..011aa015d843e 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// void push_back(value_type&& x);
+// void push_back(value_type&& x); // constexpr since C++26// constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.push_back(MoveOnly(1));
@@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(2));
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
index 3b5f74a217a2f..7ec18e8418225 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void push_front(const value_type& x);
+// void push_front(const value_type& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<int> c;
for (int i = 0; i < 5; ++i)
@@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
index 0d41b8fd8553d..930b6af5f2431 100644
--- a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
@@ -10,7 +10,7 @@
// <list>
-// void push_front(value_type&& x);
+// void push_front(value_type&& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -19,7 +19,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::list<MoveOnly> l1;
l1.push_front(MoveOnly(1));
@@ -41,5 +41,14 @@ int main(int, char**) {
assert(l1.back() == MoveOnly(1));
}
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp
index 7f82f65fd493b..19ea940cb2a08 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void merge(list& x);
+// void merge(list& x); // constexpr since C++26
// If (addressof(x) == this) does nothing; otherwise ...
#include <list>
@@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@@ -49,5 +49,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
index 13241909c6e5b..974700926db6c 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// template <class Compare> void merge(list& x, Compare comp);
+// template <class Compare> void merge(list& x, Compare comp); // constexpr since C++26
// If (addressof(x) == this) does nothing; otherwise ...
#include <list>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {10, 9, 7, 3, 1};
int a2[] = {11, 8, 6, 5, 4, 2, 0};
@@ -49,5 +49,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
index 238ea9b69ea2e..9bf677b8745c6 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// void remove(const value_type& value); // pre-c++20
-// size_type remove(const value_type& value); // c++20 and later
+// size_type remove(const value_type& value); // c++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@@ -18,22 +18,22 @@
#include "min_allocator.h"
struct S {
- S(int i) : i_(new int(i)) {}
- S(const S& rhs) : i_(new int(*rhs.i_)) {}
- S& operator=(const S& rhs) {
+ TEST_CONSTEXPR_CXX20 S(int i) : i_(new int(i)) {}
+ TEST_CONSTEXPR_CXX20 S(const S& rhs) : i_(new int(*rhs.i_)) {}
+ TEST_CONSTEXPR_CXX14 S& operator=(const S& rhs) {
*i_ = *rhs.i_;
return *this;
}
- ~S() {
+ TEST_CONSTEXPR_CXX20 ~S() {
delete i_;
i_ = NULL;
}
- bool operator==(const S& rhs) const { return *i_ == *rhs.i_; }
- int get() const { return *i_; }
+ TEST_CONSTEXPR bool operator==(const S& rhs) const { return *i_ == *rhs.i_; }
+ TEST_CONSTEXPR int get() const { return *i_; }
int* i_;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3, 4};
int a2[] = {1, 2, 4};
@@ -101,5 +101,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
index 510cb361142b4..c7ee09530ed9c 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// template <class Pred> void remove_if(Pred pred); // before C++20
-// template <class Pred> size_type remove_if(Pred pred); // c++20 and later
+// template <class Pred> size_type remove_if(Pred pred); // c++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@@ -19,22 +19,22 @@
#include "min_allocator.h"
#include "counting_predicates.h"
-bool even(int i) { return i % 2 == 0; }
+TEST_CONSTEXPR bool even(int i) { return i % 2 == 0; }
-bool g(int i) { return i < 3; }
+TEST_CONSTEXPR bool g(int i) { return i < 3; }
struct PredLWG526 {
- PredLWG526(int i) : i_(i) {}
- ~PredLWG526() { i_ = -32767; }
- bool operator()(const PredLWG526& p) const { return p.i_ == i_; }
+ TEST_CONSTEXPR_CXX20 PredLWG526(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 ~PredLWG526() { i_ = -32767; }
+ TEST_CONSTEXPR bool operator()(const PredLWG526& p) const { return p.i_ == i_; }
- bool operator==(int i) const { return i == i_; }
+ TEST_CONSTEXPR bool operator==(int i) const { return i == i_; }
int i_;
};
typedef unary_counting_predicate<bool (*)(int), int> Predicate;
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 2, 3, 4};
int a2[] = {3, 4};
@@ -92,5 +92,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
index 5b91ad0224be6..43e894f5e83a9 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void reverse();
+// void reverse(); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
@@ -34,5 +34,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
index 892419f6ac964..34ead09110a38 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void sort();
+// void sort(); // constexpr since C++26
#include <algorithm>
#include <list>
@@ -58,7 +58,7 @@ void test_stable(int N) {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
@@ -76,8 +76,19 @@ int main(int, char**) {
}
#endif
- for (int i = 0; i < 40; ++i)
- test_stable(i);
+ if (!TEST_IS_CONSTANT_EVALUATED) {
+ for (int i = 0; i < 40; ++i)
+ test_stable(i);
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
index 4997022819919..a24f187f4b4ef 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// template <class Compare> sort(Compare comp);
+// template <class Compare> sort(Compare comp); // constexpr since C++26
#include <list>
#include <functional>
@@ -76,7 +76,7 @@ void test_stable(int N) {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
@@ -85,37 +85,48 @@ int main(int, char**) {
assert(c1 == std::list<int>(a2, a2 + sizeof(a2) / sizeof(a2[0])));
}
+ if (!TEST_IS_CONSTANT_EVALUATED) {
// Test with throwing comparison; make sure that nothing is lost.
// This is (sort of) LWG #2824
#ifndef TEST_HAS_NO_EXCEPTIONS
- {
- int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
- const int sz = sizeof(a1) / sizeof(a1[0]);
- for (int i = 0; i < 10; ++i) {
- std::list<int> c1(a1, a1 + sz);
- try {
- throwingLess<int> comp(i);
- c1.sort(std::cref(comp));
- } catch (int) {
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ const int sz = sizeof(a1) / sizeof(a1[0]);
+ for (int i = 0; i < 10; ++i) {
+ std::list<int> c1(a1, a1 + sz);
+ try {
+ throwingLess<int> comp(i);
+ c1.sort(std::cref(comp));
+ } catch (int) {
+ }
+ assert((c1.size() == sz));
+ assert((std::is_permutation(c1.begin(), c1.end(), a1)));
}
- assert((c1.size() == sz));
- assert((std::is_permutation(c1.begin(), c1.end(), a1)));
}
- }
#endif
#if TEST_STD_VER >= 11
- {
- int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
- int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
- std::list<int, min_allocator<int>> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));
- c1.sort(std::greater<int>());
- assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + sizeof(a2) / sizeof(a2[0]))));
- }
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int, min_allocator<int>> c1(a1, a1 + sizeof(a1) / sizeof(a1[0]));
+ c1.sort(std::greater<int>());
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2 + sizeof(a2) / sizeof(a2[0]))));
+ }
#endif
- for (int i = 0; i < 40; ++i)
- test_stable(i);
+ for (int i = 0; i < 40; ++i)
+ test_stable(i);
+ }
+
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
index 4b40876e3bb7d..0f1cfefab34e7 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void splice(const_iterator position, list& x);
+// void splice(const_iterator position, list& x); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@@ -780,5 +780,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
index db71fe17a06eb..38dce58dc3904 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@@ -334,5 +334,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
index b77b6a26440d5..8fca21c81c66d 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
@@ -8,7 +8,7 @@
// <list>
-// void splice(const_iterator position, list& x, iterator first, iterator last);
+// void splice(const_iterator position, list& x, iterator first, iterator last); // constexpr since C++26
#include <list>
#include <cassert>
@@ -16,7 +16,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
int a1[] = {1, 2, 3};
int a2[] = {4, 5, 6};
{
@@ -214,5 +214,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
index c08e348218f95..c2fa54f425534 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// void unique(); // before C++20
-// size_type unique(); // C++20 and later
+// size_type unique(); // C++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@@ -17,7 +17,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
@@ -46,5 +46,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
index 1d3a8e0c426aa..830e54a3288d0 100644
--- a/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// template <class BinaryPred> void unique(BinaryPred pred); // before C++20
-// template <class BinaryPred> size_type unique(BinaryPred pred); // C++20 and later
+// template <class BinaryPred> size_type unique(BinaryPred pred); // C++20 and later; constexpr since C++26
#include <list>
#include <cassert>
@@ -18,18 +18,18 @@
#include "test_macros.h"
#include "min_allocator.h"
-bool g(int x, int y) { return x == y; }
+TEST_CONSTEXPR bool g(int x, int y) { return x == y; }
struct PredLWG526 {
- PredLWG526(int i) : i_(i) {}
- ~PredLWG526() { i_ = -32767; }
- bool operator()(const PredLWG526& lhs, const PredLWG526& rhs) const { return lhs.i_ == rhs.i_; }
+ TEST_CONSTEXPR_CXX20 PredLWG526(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX20 ~PredLWG526() { i_ = -32767; }
+ TEST_CONSTEXPR bool operator()(const PredLWG526& lhs, const PredLWG526& rhs) const { return lhs.i_ == rhs.i_; }
- bool operator==(int i) const { return i == i_; }
+ TEST_CONSTEXPR bool operator==(int i) const { return i == i_; }
int i_;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
int a2[] = {2, 1, 4, 3};
@@ -75,5 +75,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
index 1e9c71131d80a..32efddb06920c 100644
--- a/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
@@ -9,7 +9,7 @@
// <list>
// template <class T, class Alloc>
-// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y); // constexpr since C++26
#include <list>
#include <cassert>
@@ -17,7 +17,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
int a1[] = {1, 3, 7, 9, 10};
int a2[] = {0, 2, 4, 5, 6, 8, 11};
@@ -133,5 +133,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
index a4b1622a04bee..037c7d07c4cb8 100644
--- a/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
@@ -12,7 +12,7 @@
// void swap(list& c)
// noexcept(!allocator_type::propagate_on_container_swap::value ||
-// __is_nothrow_swappable<allocator_type>::value);
+// __is_nothrow_swappable<allocator_type>::value); // constexpr since C++26
//
// In C++17, the standard says that swap shall have:
// noexcept(allocator_traits<Allocator>::is_always_equal::value);
@@ -52,7 +52,7 @@ struct some_alloc2 {
typedef std::true_type is_always_equal;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::list<MoveOnly> C;
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
@@ -84,5 +84,14 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+
+int main(int, char**) {
+ assert(test());
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
+
return 0;
}
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
index 9cd3c3bc941c0..be4f9bfd6bcc6 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/list.version.compile.pass.cpp
@@ -17,6 +17,7 @@
/* Constant Value
__cpp_lib_allocator_traits_is_always_equal 201411L [C++17]
+ __cpp_lib_constexpr_list 202502L [C++26]
__cpp_lib_containers_ranges 202202L [C++23]
__cpp_lib_default_template_type_for_algorithm_values 202403L [C++26]
__cpp_lib_erase_if 202002L [C++20]
@@ -34,6 +35,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@@ -64,6 +69,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should not be defined before c++17"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@@ -97,6 +106,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++17"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@@ -136,6 +149,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++20"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should not be defined before c++23"
# endif
@@ -181,6 +198,10 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++23"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifndef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should be defined in c++23"
# endif
@@ -229,6 +250,13 @@
# error "__cpp_lib_allocator_traits_is_always_equal should have the value 201411L in c++26"
# endif
+# ifndef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should be defined in c++26"
+# endif
+# if __cpp_lib_constexpr_list != 202502L
+# error "__cpp_lib_constexpr_list should have the value 202502L in c++26"
+# endif
+
# ifndef __cpp_lib_containers_ranges
# error "__cpp_lib_containers_ranges should be defined in c++26"
# endif
diff --git a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
index 1e4465d515e6b..9096d0e16f849 100644
--- a/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
+++ b/libcxx/test/std/language.support/support.limits/support.limits.general/version.version.compile.pass.cpp
@@ -63,6 +63,7 @@
__cpp_lib_constexpr_dynamic_alloc 201907L [C++20]
__cpp_lib_constexpr_functional 201907L [C++20]
__cpp_lib_constexpr_iterator 201811L [C++20]
+ __cpp_lib_constexpr_list 202502L [C++26]
__cpp_lib_constexpr_memory 201811L [C++20]
202202L [C++23]
__cpp_lib_constexpr_new 202406L [C++26]
@@ -438,6 +439,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@@ -1314,6 +1319,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@@ -2292,6 +2301,10 @@
# error "__cpp_lib_constexpr_iterator should not be defined before c++20"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifdef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should not be defined before c++20"
# endif
@@ -3516,6 +3529,10 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++20"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++20"
# endif
@@ -4956,6 +4973,10 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++23"
# endif
+# ifdef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should not be defined before c++26"
+# endif
+
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++23"
# endif
@@ -6624,6 +6645,13 @@
# error "__cpp_lib_constexpr_iterator should have the value 201811L in c++26"
# endif
+# ifndef __cpp_lib_constexpr_list
+# error "__cpp_lib_constexpr_list should be defined in c++26"
+# endif
+# if __cpp_lib_constexpr_list != 202502L
+# error "__cpp_lib_constexpr_list should have the value 202502L in c++26"
+# endif
+
# ifndef __cpp_lib_constexpr_memory
# error "__cpp_lib_constexpr_memory should be defined in c++26"
# endif
diff --git a/libcxx/test/support/counting_predicates.h b/libcxx/test/support/counting_predicates.h
index db7ee481991c4..6d4859a737b89 100644
--- a/libcxx/test/support/counting_predicates.h
+++ b/libcxx/test/support/counting_predicates.h
@@ -16,41 +16,46 @@
template <typename Predicate, typename Arg>
struct unary_counting_predicate {
public:
- typedef Arg argument_type;
- typedef bool result_type;
+ typedef Arg argument_type;
+ typedef bool result_type;
- unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
- unary_counting_predicate(const unary_counting_predicate&) = default;
- unary_counting_predicate& operator=(const unary_counting_predicate&) = default;
- ~unary_counting_predicate() {}
+ TEST_CONSTEXPR_CXX20 unary_counting_predicate(Predicate p) : p_(p), count_(0) {}
+ unary_counting_predicate(const unary_counting_predicate&) = default;
+ unary_counting_predicate& operator=(const unary_counting_predicate&) = default;
+ TEST_CONSTEXPR_CXX20 ~unary_counting_predicate() {}
- bool operator () (const Arg &a) const { ++count_; return p_(a); }
- std::size_t count() const { return count_; }
- void reset() { count_ = 0; }
+ TEST_CONSTEXPR_CXX14 bool operator()(const Arg& a) const {
+ ++count_;
+ return p_(a);
+ }
+ TEST_CONSTEXPR std::size_t count() const { return count_; }
+ TEST_CONSTEXPR void reset() { count_ = 0; }
private:
- Predicate p_;
- mutable std::size_t count_;
+ Predicate p_;
+ mutable std::size_t count_;
};
-
-template <typename Predicate, typename Arg1, typename Arg2=Arg1>
+template <typename Predicate, typename Arg1, typename Arg2 = Arg1>
struct binary_counting_predicate {
public:
- typedef Arg1 first_argument_type;
- typedef Arg2 second_argument_type;
- typedef bool result_type;
+ typedef Arg1 first_argument_type;
+ typedef Arg2 second_argument_type;
+ typedef bool result_type;
- binary_counting_predicate ( Predicate p ) : p_(p), count_(0) {}
- ~binary_counting_predicate() {}
+ binary_counting_predicate(Predicate p) : p_(p), count_(0) {}
+ ~binary_counting_predicate() {}
- bool operator () (const Arg1 &a1, const Arg2 &a2) const { ++count_; return p_(a1, a2); }
- std::size_t count() const { return count_; }
- void reset() { count_ = 0; }
+ bool operator()(const Arg1& a1, const Arg2& a2) const {
+ ++count_;
+ return p_(a1, a2);
+ }
+ std::size_t count() const { return count_; }
+ void reset() { count_ = 0; }
private:
- Predicate p_;
- mutable std::size_t count_;
+ Predicate p_;
+ mutable std::size_t count_;
};
#if TEST_STD_VER > 14
@@ -65,13 +70,13 @@ class counting_predicate {
constexpr counting_predicate(Predicate pred, int& count) : pred_(std::move(pred)), count_(&count) {}
template <class... Args>
- constexpr decltype(auto) operator()(Args&& ...args) {
+ constexpr decltype(auto) operator()(Args&&... args) {
++(*count_);
return pred_(std::forward<Args>(args)...);
}
template <class... Args>
- constexpr decltype(auto) operator()(Args&& ...args) const {
+ constexpr decltype(auto) operator()(Args&&... args) const {
++(*count_);
return pred_(std::forward<Args>(args)...);
}
diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h
index 0be7ee0554ca9..359e4573925e8 100644
--- a/libcxx/test/support/min_allocator.h
+++ b/libcxx/test/support/min_allocator.h
@@ -22,409 +22,399 @@
#include "test_macros.h"
template <class T>
-class bare_allocator
-{
+class bare_allocator {
public:
- typedef T value_type;
+ typedef T value_type;
- bare_allocator() TEST_NOEXCEPT {}
+ bare_allocator() TEST_NOEXCEPT {}
- template <class U>
- bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
+ template <class U>
+ bare_allocator(bare_allocator<U>) TEST_NOEXCEPT {}
- T* allocate(std::size_t n)
- {
- return static_cast<T*>(::operator new(n*sizeof(T)));
- }
+ T* allocate(std::size_t n) { return static_cast<T*>(::operator new(n * sizeof(T))); }
- void deallocate(T* p, std::size_t)
- {
- return ::operator delete(static_cast<void*>(p));
- }
+ void deallocate(T* p, std::size_t) { return ::operator delete(static_cast<void*>(p)); }
- friend bool operator==(bare_allocator, bare_allocator) {return true;}
- friend bool operator!=(bare_allocator x, bare_allocator y) {return !(x == y);}
+ friend bool operator==(bare_allocator, bare_allocator) { return true; }
+ friend bool operator!=(bare_allocator x, bare_allocator y) { return !(x == y); }
};
-
template <class T>
-class no_default_allocator
-{
+class no_default_allocator {
#if TEST_STD_VER >= 11
- no_default_allocator() = delete;
+ no_default_allocator() = delete;
#else
- no_default_allocator();
+ no_default_allocator();
#endif
- struct construct_tag {};
- explicit no_default_allocator(construct_tag) {}
+ struct construct_tag {};
+ TEST_CONSTEXPR_CXX20 explicit no_default_allocator(construct_tag) {}
public:
- static no_default_allocator create() {
- construct_tag tag;
- return no_default_allocator(tag);
- }
+ TEST_CONSTEXPR_CXX20 static no_default_allocator create() {
+ construct_tag tag;
+ return no_default_allocator(tag);
+ }
public:
- typedef T value_type;
+ typedef T value_type;
- template <class U>
- no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
+ template <class U>
+ TEST_CONSTEXPR_CXX20 no_default_allocator(no_default_allocator<U>) TEST_NOEXCEPT {}
- T* allocate(std::size_t n)
- {
- return static_cast<T*>(::operator new(n*sizeof(T)));
- }
+ TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return static_cast<T*>(std::allocator<T>().allocate(n)); }
- void deallocate(T* p, std::size_t)
- {
- return ::operator delete(static_cast<void*>(p));
- }
+ TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
- friend bool operator==(no_default_allocator, no_default_allocator) {return true;}
- friend bool operator!=(no_default_allocator x, no_default_allocator y) {return !(x == y);}
+ friend TEST_CONSTEXPR bool operator==(no_default_allocator, no_default_allocator) { return true; }
+ friend TEST_CONSTEXPR bool operator!=(no_default_allocator x, no_default_allocator y) { return !(x == y); }
};
struct malloc_allocator_base {
- static std::size_t outstanding_bytes;
- static std::size_t alloc_count;
- static std::size_t dealloc_count;
- static bool disable_default_constructor;
-
- static std::size_t outstanding_alloc() {
- assert(alloc_count >= dealloc_count);
- return (alloc_count - dealloc_count);
- }
-
- static void reset() {
- assert(outstanding_alloc() == 0);
- disable_default_constructor = false;
- outstanding_bytes = 0;
- alloc_count = 0;
- dealloc_count = 0;
- }
+ static std::size_t outstanding_bytes;
+ static std::size_t alloc_count;
+ static std::size_t dealloc_count;
+ static bool disable_default_constructor;
+
+ static std::size_t outstanding_alloc() {
+ assert(alloc_count >= dealloc_count);
+ return (alloc_count - dealloc_count);
+ }
+
+ static void reset() {
+ assert(outstanding_alloc() == 0);
+ disable_default_constructor = false;
+ outstanding_bytes = 0;
+ alloc_count = 0;
+ dealloc_count = 0;
+ }
};
-size_t malloc_allocator_base::outstanding_bytes = 0;
-size_t malloc_allocator_base::alloc_count = 0;
-size_t malloc_allocator_base::dealloc_count = 0;
+size_t malloc_allocator_base::outstanding_bytes = 0;
+size_t malloc_allocator_base::alloc_count = 0;
+size_t malloc_allocator_base::dealloc_count = 0;
bool malloc_allocator_base::disable_default_constructor = false;
-
template <class T>
-class malloc_allocator : public malloc_allocator_base
-{
+class malloc_allocator : public malloc_allocator_base {
public:
- typedef T value_type;
-
- malloc_allocator() TEST_NOEXCEPT { assert(!disable_default_constructor); }
-
- template <class U>
- malloc_allocator(malloc_allocator<U>) TEST_NOEXCEPT {}
-
- T* allocate(std::size_t n)
- {
- const std::size_t nbytes = n*sizeof(T);
- ++alloc_count;
- outstanding_bytes += nbytes;
- return static_cast<T*>(std::malloc(nbytes));
- }
-
- void deallocate(T* p, std::size_t n)
- {
- const std::size_t nbytes = n*sizeof(T);
- ++dealloc_count;
- outstanding_bytes -= nbytes;
- std::free(static_cast<void*>(p));
- }
-
- friend bool operator==(malloc_allocator, malloc_allocator) {return true;}
- friend bool operator!=(malloc_allocator x, malloc_allocator y) {return !(x == y);}
+ typedef T value_type;
+
+ malloc_allocator() TEST_NOEXCEPT { assert(!disable_default_constructor); }
+
+ template <class U>
+ malloc_allocator(malloc_allocator<U>) TEST_NOEXCEPT {}
+
+ T* allocate(std::size_t n) {
+ const std::size_t nbytes = n * sizeof(T);
+ ++alloc_count;
+ outstanding_bytes += nbytes;
+ return static_cast<T*>(std::malloc(nbytes));
+ }
+
+ void deallocate(T* p, std::size_t n) {
+ const std::size_t nbytes = n * sizeof(T);
+ ++dealloc_count;
+ outstanding_bytes -= nbytes;
+ std::free(static_cast<void*>(p));
+ }
+
+ friend bool operator==(malloc_allocator, malloc_allocator) { return true; }
+ friend bool operator!=(malloc_allocator x, malloc_allocator y) { return !(x == y); }
};
template <class T>
-struct cpp03_allocator : bare_allocator<T>
-{
- typedef T value_type;
- typedef value_type* pointer;
-
- static bool construct_called;
-
- // Returned value is not used but it's not prohibited.
- pointer construct(pointer p, const value_type& val)
- {
- ::new(p) value_type(val);
- construct_called = true;
- return p;
- }
-
- std::size_t max_size() const
- {
- return UINT_MAX / sizeof(T);
- }
+struct cpp03_allocator : bare_allocator<T> {
+ typedef T value_type;
+ typedef value_type* pointer;
+
+ static bool construct_called;
+
+ // Returned value is not used but it's not prohibited.
+ pointer construct(pointer p, const value_type& val) {
+ ::new (p) value_type(val);
+ construct_called = true;
+ return p;
+ }
+
+ std::size_t max_size() const { return UINT_MAX / sizeof(T); }
};
-template <class T> bool cpp03_allocator<T>::construct_called = false;
+template <class T>
+bool cpp03_allocator<T>::construct_called = false;
template <class T>
-struct cpp03_overload_allocator : bare_allocator<T>
-{
- typedef T value_type;
- typedef value_type* pointer;
-
- static bool construct_called;
-
- void construct(pointer p, const value_type& val)
- {
- construct(p, val, std::is_class<T>());
- }
- void construct(pointer p, const value_type& val, std::true_type)
- {
- ::new(p) value_type(val);
- construct_called = true;
- }
- void construct(pointer p, const value_type& val, std::false_type)
- {
- ::new(p) value_type(val);
- construct_called = true;
- }
-
- std::size_t max_size() const
- {
- return UINT_MAX / sizeof(T);
- }
+struct cpp03_overload_allocator : bare_allocator<T> {
+ typedef T value_type;
+ typedef value_type* pointer;
+
+ static bool construct_called;
+
+ void construct(pointer p, const value_type& val) { construct(p, val, std::is_class<T>()); }
+ void construct(pointer p, const value_type& val, std::true_type) {
+ ::new (p) value_type(val);
+ construct_called = true;
+ }
+ void construct(pointer p, const value_type& val, std::false_type) {
+ ::new (p) value_type(val);
+ construct_called = true;
+ }
+
+ std::size_t max_size() const { return UINT_MAX / sizeof(T); }
};
-template <class T> bool cpp03_overload_allocator<T>::construct_called = false;
+template <class T>
+bool cpp03_overload_allocator<T>::construct_called = false;
-template <class T, class = std::integral_constant<std::size_t, 0> > class min_pointer;
-template <class T, class ID> class min_pointer<const T, ID>;
-template <class ID> class min_pointer<void, ID>;
-template <class ID> class min_pointer<const void, ID>;
-template <class T> class min_allocator;
+template <class T, class = std::integral_constant<std::size_t, 0> >
+class min_pointer;
+template <class T, class ID>
+class min_pointer<const T, ID>;
+template <class ID>
+class min_pointer<void, ID>;
+template <class ID>
+class min_pointer<const void, ID>;
+template <class T>
+class min_allocator;
template <class ID>
-class min_pointer<const void, ID>
-{
- const void* ptr_;
+class min_pointer<const void, ID> {
+ const void* ptr_;
+
public:
- min_pointer() TEST_NOEXCEPT = default;
- min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
- template <class T>
- min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
+ min_pointer() TEST_NOEXCEPT = default;
+ min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ template <class T>
+ min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
- explicit operator bool() const {return ptr_ != nullptr;}
+ explicit operator bool() const { return ptr_ != nullptr; }
- friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
- friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
- template <class U, class XID> friend class min_pointer;
+ friend bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
+ friend bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
+ template <class U, class XID>
+ friend class min_pointer;
};
template <class ID>
-class min_pointer<void, ID>
-{
- void* ptr_;
+class min_pointer<void, ID> {
+ void* ptr_;
+
public:
- min_pointer() TEST_NOEXCEPT = default;
- TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
- template <class T,
- class = typename std::enable_if
- <
- !std::is_const<T>::value
- >::type
- >
- TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
-
- TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
-
- TEST_CONSTEXPR_CXX14 friend bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
- TEST_CONSTEXPR_CXX14 friend bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
- template <class U, class XID> friend class min_pointer;
+ min_pointer() TEST_NOEXCEPT = default;
+ TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ template <class T, class = typename std::enable_if< !std::is_const<T>::value >::type >
+ TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) TEST_NOEXCEPT : ptr_(p.ptr_) {}
+
+ TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
+
+ TEST_CONSTEXPR_CXX14 friend bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
+ TEST_CONSTEXPR_CXX14 friend bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
+ template <class U, class XID>
+ friend class min_pointer;
};
template <class T, class ID>
-class min_pointer
-{
- T* ptr_;
+class min_pointer {
+ T* ptr_;
+
+ TEST_CONSTEXPR_CXX14 explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
- TEST_CONSTEXPR_CXX14 explicit min_pointer(T* p) TEST_NOEXCEPT : ptr_(p) {}
public:
- min_pointer() TEST_NOEXCEPT = default;
- TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
- TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
-
- TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
-
- typedef std::ptrdiff_t difference_type;
- typedef T& reference;
- typedef T* pointer;
- typedef T value_type;
- typedef std::random_access_iterator_tag iterator_category;
-
- TEST_CONSTEXPR_CXX14 reference operator*() const {return *ptr_;}
- TEST_CONSTEXPR_CXX14 pointer operator->() const {return ptr_;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator++() {++ptr_; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator--() {--ptr_; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
-
- TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const
- {
- min_pointer tmp(*this);
- tmp += n;
- return tmp;
- }
-
- friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x)
- {
- return x + n;
- }
-
- TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const
- {
- min_pointer tmp(*this);
- tmp -= n;
- return tmp;
- }
-
- friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y)
- {
- return x.ptr_ - y.ptr_;
- }
-
- TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const {return ptr_[n];}
-
- friend TEST_CONSTEXPR_CXX14 bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
- friend TEST_CONSTEXPR_CXX14 bool operator> (min_pointer x, min_pointer y) {return y < x;}
- friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
- friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
-
- static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(T& t) {return min_pointer(std::addressof(t));}
-
- friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
- friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) {return !(x == y);}
- template <class U, class XID> friend class min_pointer;
- template <class U> friend class min_allocator;
+ min_pointer() TEST_NOEXCEPT = default;
+ TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {}
+ TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<void, ID> p) TEST_NOEXCEPT : ptr_(static_cast<T*>(p.ptr_)) {}
+
+ TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
+
+ typedef std::ptrdiff_t difference_type;
+ typedef T& reference;
+ typedef T* pointer;
+ typedef T value_type;
+ typedef std::random_access_iterator_tag iterator_category;
+
+ TEST_CONSTEXPR_CXX14 reference operator*() const { return *ptr_; }
+ TEST_CONSTEXPR_CXX14 pointer operator->() const { return ptr_; }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator++() {
+ ++ptr_;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {
+ min_pointer tmp(*this);
+ ++ptr_;
+ return tmp;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator--() {
+ --ptr_;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {
+ min_pointer tmp(*this);
+ --ptr_;
+ return tmp;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {
+ ptr_ += n;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {
+ ptr_ -= n;
+ return *this;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const {
+ min_pointer tmp(*this);
+ tmp += n;
+ return tmp;
+ }
+
+ friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x) { return x + n; }
+
+ TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const {
+ min_pointer tmp(*this);
+ tmp -= n;
+ return tmp;
+ }
+
+ friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y) { return x.ptr_ - y.ptr_; }
+
+ TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const { return ptr_[n]; }
+
+ friend TEST_CONSTEXPR_CXX14 bool operator<(min_pointer x, min_pointer y) { return x.ptr_ < y.ptr_; }
+ friend TEST_CONSTEXPR_CXX14 bool operator>(min_pointer x, min_pointer y) { return y < x; }
+ friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) { return !(y < x); }
+ friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) { return !(x < y); }
+
+ static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(T& t) { return min_pointer(std::addressof(t)); }
+
+ friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) { return !(x == y); }
+ template <class U, class XID>
+ friend class min_pointer;
+ template <class U>
+ friend class min_allocator;
};
template <class T, class ID>
-class min_pointer<const T, ID>
-{
- const T* ptr_;
+class min_pointer<const T, ID> {
+ const T* ptr_;
+
+ TEST_CONSTEXPR_CXX14 explicit min_pointer(const T* p) : ptr_(p) {}
- TEST_CONSTEXPR_CXX14 explicit min_pointer(const T* p) : ptr_(p) {}
public:
- min_pointer() TEST_NOEXCEPT = default;
- TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) : ptr_(nullptr) {}
- TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) : ptr_(p.ptr_) {}
- TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<const void, ID> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
-
- TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;}
-
- typedef std::ptrdiff_t difference_type;
- typedef const T& reference;
- typedef const T* pointer;
- typedef const T value_type;
- typedef std::random_access_iterator_tag iterator_category;
-
- TEST_CONSTEXPR_CXX14 reference operator*() const {return *ptr_;}
- TEST_CONSTEXPR_CXX14 pointer operator->() const {return ptr_;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator++() {++ptr_; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {min_pointer tmp(*this); ++ptr_; return tmp;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator--() {--ptr_; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {min_pointer tmp(*this); --ptr_; return tmp;}
-
- TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {ptr_ += n; return *this;}
- TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {ptr_ -= n; return *this;}
-
- TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const
- {
- min_pointer tmp(*this);
- tmp += n;
- return tmp;
- }
-
- friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x)
- {
- return x + n;
- }
-
- TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const
- {
- min_pointer tmp(*this);
- tmp -= n;
- return tmp;
- }
-
- friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y)
- {
- return x.ptr_ - y.ptr_;
- }
-
- TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const {return ptr_[n];}
-
- friend TEST_CONSTEXPR_CXX14 bool operator< (min_pointer x, min_pointer y) {return x.ptr_ < y.ptr_;}
- friend TEST_CONSTEXPR_CXX14 bool operator> (min_pointer x, min_pointer y) {return y < x;}
- friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) {return !(y < x);}
- friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) {return !(x < y);}
-
- static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(const T& t) {return min_pointer(std::addressof(t));}
-
- friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) {return x.ptr_ == y.ptr_;}
- friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) {return x.ptr_ != y.ptr_;}
- friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, std::nullptr_t) {return x.ptr_ == nullptr;}
- friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, std::nullptr_t) {return x.ptr_ != nullptr;}
- friend TEST_CONSTEXPR_CXX14 bool operator==(std::nullptr_t, min_pointer x) {return x.ptr_ == nullptr;}
- friend TEST_CONSTEXPR_CXX14 bool operator!=(std::nullptr_t, min_pointer x) {return x.ptr_ != nullptr;}
- template <class U, class XID> friend class min_pointer;
+ min_pointer() TEST_NOEXCEPT = default;
+ TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) : ptr_(nullptr) {}
+ TEST_CONSTEXPR_CXX14 min_pointer(min_pointer<T, ID> p) : ptr_(p.ptr_) {}
+ TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer<const void, ID> p) : ptr_(static_cast<const T*>(p.ptr_)) {}
+
+ TEST_CONSTEXPR_CXX14 explicit operator bool() const { return ptr_ != nullptr; }
+
+ typedef std::ptrdiff_t difference_type;
+ typedef const T& reference;
+ typedef const T* pointer;
+ typedef const T value_type;
+ typedef std::random_access_iterator_tag iterator_category;
+
+ TEST_CONSTEXPR_CXX14 reference operator*() const { return *ptr_; }
+ TEST_CONSTEXPR_CXX14 pointer operator->() const { return ptr_; }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator++() {
+ ++ptr_;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer operator++(int) {
+ min_pointer tmp(*this);
+ ++ptr_;
+ return tmp;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator--() {
+ --ptr_;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer operator--(int) {
+ min_pointer tmp(*this);
+ --ptr_;
+ return tmp;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer& operator+=(difference_type n) {
+ ptr_ += n;
+ return *this;
+ }
+ TEST_CONSTEXPR_CXX14 min_pointer& operator-=(difference_type n) {
+ ptr_ -= n;
+ return *this;
+ }
+
+ TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n) const {
+ min_pointer tmp(*this);
+ tmp += n;
+ return tmp;
+ }
+
+ friend TEST_CONSTEXPR_CXX14 min_pointer operator+(difference_type n, min_pointer x) { return x + n; }
+
+ TEST_CONSTEXPR_CXX14 min_pointer operator-(difference_type n) const {
+ min_pointer tmp(*this);
+ tmp -= n;
+ return tmp;
+ }
+
+ friend TEST_CONSTEXPR_CXX14 difference_type operator-(min_pointer x, min_pointer y) { return x.ptr_ - y.ptr_; }
+
+ TEST_CONSTEXPR_CXX14 reference operator[](difference_type n) const { return ptr_[n]; }
+
+ friend TEST_CONSTEXPR_CXX14 bool operator<(min_pointer x, min_pointer y) { return x.ptr_ < y.ptr_; }
+ friend TEST_CONSTEXPR_CXX14 bool operator>(min_pointer x, min_pointer y) { return y < x; }
+ friend TEST_CONSTEXPR_CXX14 bool operator<=(min_pointer x, min_pointer y) { return !(y < x); }
+ friend TEST_CONSTEXPR_CXX14 bool operator>=(min_pointer x, min_pointer y) { return !(x < y); }
+
+ static TEST_CONSTEXPR_CXX14 min_pointer pointer_to(const T& t) { return min_pointer(std::addressof(t)); }
+
+ friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, min_pointer y) { return x.ptr_ == y.ptr_; }
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, min_pointer y) { return x.ptr_ != y.ptr_; }
+ friend TEST_CONSTEXPR_CXX14 bool operator==(min_pointer x, std::nullptr_t) { return x.ptr_ == nullptr; }
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(min_pointer x, std::nullptr_t) { return x.ptr_ != nullptr; }
+ friend TEST_CONSTEXPR_CXX14 bool operator==(std::nullptr_t, min_pointer x) { return x.ptr_ == nullptr; }
+ friend TEST_CONSTEXPR_CXX14 bool operator!=(std::nullptr_t, min_pointer x) { return x.ptr_ != nullptr; }
+ template <class U, class XID>
+ friend class min_pointer;
};
template <class T>
-class min_allocator
-{
+class min_allocator {
public:
- typedef T value_type;
- typedef min_pointer<T> pointer;
+ typedef T value_type;
+ typedef min_pointer<T> pointer;
- min_allocator() = default;
- template <class U>
- TEST_CONSTEXPR_CXX20 min_allocator(min_allocator<U>) {}
+ min_allocator() = default;
+ template <class U>
+ TEST_CONSTEXPR_CXX20 min_allocator(min_allocator<U>) {}
- TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator<T>().allocate(n)); }
+ TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator<T>().allocate(n)); }
- TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
+ TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator<T>().deallocate(p.ptr_, n); }
- TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) {return true;}
- TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);}
+ TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) { return true; }
+ TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) { return !(x == y); }
};
template <class T>
-class explicit_allocator
-{
+class explicit_allocator {
public:
- typedef T value_type;
+ typedef T value_type;
- TEST_CONSTEXPR_CXX20 explicit_allocator() TEST_NOEXCEPT {}
+ TEST_CONSTEXPR_CXX20 explicit_allocator() TEST_NOEXCEPT {}
- template <class U>
- TEST_CONSTEXPR_CXX20 explicit explicit_allocator(explicit_allocator<U>) TEST_NOEXCEPT {}
+ template <class U>
+ TEST_CONSTEXPR_CXX20 explicit explicit_allocator(explicit_allocator<U>) TEST_NOEXCEPT {}
- TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n)
- {
- return static_cast<T*>(std::allocator<T>().allocate(n));
- }
+ TEST_CONSTEXPR_CXX20 T* allocate(std::size_t n) { return static_cast<T*>(std::allocator<T>().allocate(n)); }
- TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n)
- {
- std::allocator<T>().deallocate(p, n);
- }
+ TEST_CONSTEXPR_CXX20 void deallocate(T* p, std::size_t n) { std::allocator<T>().deallocate(p, n); }
- TEST_CONSTEXPR_CXX20 friend bool operator==(explicit_allocator, explicit_allocator) {return true;}
- TEST_CONSTEXPR_CXX20 friend bool operator!=(explicit_allocator x, explicit_allocator y) {return !(x == y);}
+ TEST_CONSTEXPR_CXX20 friend bool operator==(explicit_allocator, explicit_allocator) { return true; }
+ TEST_CONSTEXPR_CXX20 friend bool operator!=(explicit_allocator x, explicit_allocator y) { return !(x == y); }
};
template <class T>
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 8bf7633e985d5..80f57678fc6d2 100755
--- a/libcxx/utils/generate_feature_test_macro_components.py
+++ b/libcxx/utils/generate_feature_test_macro_components.py
@@ -360,6 +360,11 @@ def add_version_header(tc):
"values": {"c++20": 201811},
"headers": ["iterator"],
},
+ {
+ "name": "__cpp_lib_constexpr_list",
+ "values": {"c++26": 202502},
+ "headers": ["list"],
+ },
{
"name": "__cpp_lib_constexpr_memory",
"values": {"c++20": 201811, "c++23": 202202},
>From 198b6e27078330a700433c31e8dca657b4809fae Mon Sep 17 00:00:00 2001
From: Peng Liu <winner245 at hotmail.com>
Date: Wed, 5 Mar 2025 22:42:09 -0500
Subject: [PATCH 2/2] Fix gcc constexpr evaluation failure
---
libcxx/include/list | 2 +-
.../sequences/list/list.capacity/resize_size.pass.cpp | 3 +--
.../containers/sequences/list/list.cons/size_type.pass.cpp | 3 +--
libcxx/test/support/counting_predicates.h | 4 ++--
4 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/libcxx/include/list b/libcxx/include/list
index 27031b90a97e0..e6ecce38dc023 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -354,7 +354,7 @@ public:
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI __base_pointer __as_link() {
return pointer_traits<__base_pointer>::pointer_to(
- *static_cast<typename pointer_traits<__base_pointer>::element_type*>(this));
+ *static_cast<typename pointer_traits<__base_pointer>::element_type*>(std::addressof(*this)));
}
};
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
index 32049b22881b9..f694d9ab26504 100644
--- a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
@@ -12,7 +12,6 @@
#include <list>
#include <cassert>
-#include <type_traits>
#include "test_macros.h"
#include "DefaultOnly.h"
@@ -35,7 +34,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(l.back() == 0);
}
#if TEST_STD_VER >= 11
- if (!std::is_constant_evaluated()) {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
{
std::list<DefaultOnly> l(10);
l.resize(5);
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
index f9c3b8c2a96c4..55371e8354a9e 100644
--- a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
+++ b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -13,7 +13,6 @@
#include <list>
#include <cassert>
#include <cstddef>
-#include <type_traits>
#include "test_macros.h"
#include "DefaultOnly.h"
@@ -88,7 +87,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*i == 0);
}
- if (!std::is_constant_evaluated()) {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
{
std::list<DefaultOnly> l(3);
assert(l.size() == 3);
diff --git a/libcxx/test/support/counting_predicates.h b/libcxx/test/support/counting_predicates.h
index 6d4859a737b89..a34e25ef02763 100644
--- a/libcxx/test/support/counting_predicates.h
+++ b/libcxx/test/support/counting_predicates.h
@@ -28,8 +28,8 @@ struct unary_counting_predicate {
++count_;
return p_(a);
}
- TEST_CONSTEXPR std::size_t count() const { return count_; }
- TEST_CONSTEXPR void reset() { count_ = 0; }
+ TEST_CONSTEXPR_CXX14 std::size_t count() const { return count_; }
+ TEST_CONSTEXPR_CXX14 void reset() { count_ = 0; }
private:
Predicate p_;
More information about the libcxx-commits
mailing list