[libcxx-commits] [libcxx] [libc++] Make `<set>` `std::set` constexpr as part of P3372R3 (PR #167241)
Vinay Deshmukh via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Nov 9 18:10:39 PST 2025
https://github.com/vinay-deshmukh updated https://github.com/llvm/llvm-project/pull/167241
>From c7046abfa4d3aaaf0bce4f8589a50221a46934b1 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 14:46:05 -0500
Subject: [PATCH 1/9] Initial patch from PR#134330
---
libcxx/include/__functional/hash.h | 9 +
.../include/__iterator/erase_if_container.h | 3 +-
libcxx/include/__node_handle | 52 +-
.../include/__numeric/saturation_arithmetic.h | 10 +-
libcxx/include/__tree | 912 +++++++++++-------
.../include/__type_traits/make_transparent.h | 4 +-
.../__utility/default_three_way_comparator.h | 2 +-
.../lazy_synth_three_way_comparator.h | 33 +-
libcxx/include/__utility/try_key_extraction.h | 12 +-
libcxx/test/support/is_transparent.h | 13 +-
libcxx/test/support/poisoned_hash_helper.h | 10 +-
libcxx/test/support/private_constructor.h | 18 +-
12 files changed, 638 insertions(+), 440 deletions(-)
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index f74f25fa6e84b..83bbf1b5e26c3 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -433,10 +433,13 @@ struct __hash_impl<long double> : __scalar_hash<long double> {
template <class _Tp>
struct hash : public __hash_impl<_Tp> {};
+#if _LIBCPP_STD_VER >= 17
+
template <>
struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {
_LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }
};
+#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Hash>
@@ -449,12 +452,18 @@ template <class _Key, class _Hash = hash<_Key> >
using __has_enabled_hash _LIBCPP_NODEBUG =
integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >;
+# if _LIBCPP_STD_VER >= 17
template <class _Type, class>
using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type;
template <class _Type, class... _Keys>
using __enable_hash_helper _LIBCPP_NODEBUG =
__enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >;
+# else
+template <class _Type, class...>
+using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
+# endif
+
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/include/__iterator/erase_if_container.h b/libcxx/include/__iterator/erase_if_container.h
index 0f87f50cd1c16..8d92d3f1b9dbe 100644
--- a/libcxx/include/__iterator/erase_if_container.h
+++ b/libcxx/include/__iterator/erase_if_container.h
@@ -22,7 +22,8 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _Container, class _Predicate>
-_LIBCPP_HIDE_FROM_ABI typename _Container::size_type __libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename _Container::size_type
+__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) {
typename _Container::size_type __old_size = __c.size();
const typename _Container::iterator __last = __c.end();
diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle
index b20b0c73a0518..58be5b9d4ddd5 100644
--- a/libcxx/include/__node_handle
+++ b/libcxx/include/__node_handle
@@ -31,29 +31,29 @@ private:
public:
// [container.node.cons], constructors, copy, and assignment
constexpr node-handle() noexcept : ptr_(), alloc_() {}
- node-handle(node-handle&&) noexcept;
- node-handle& operator=(node-handle&&);
+ constexpr node-handle(node-handle&&) noexcept; // constexpr since C++26
+ constexpr node-handle& operator=(node-handle&&); // constexpr since C++26
// [container.node.dtor], destructor
- ~node-handle();
+ constexpr ~node-handle(); // constexpr since C++26
// [container.node.observers], observers
- value_type& value() const; // not present for map containers
- key_type& key() const; // not present for set containers
- mapped_type& mapped() const; // not present for set containers
+ value_type& value() const; // not present for map containers
+ key_type& key() const; // not present for set containers
+ constexpr mapped_type& mapped() const; // not present for set containers, constexpr since C++26
- allocator_type get_allocator() const;
- explicit operator bool() const noexcept;
- [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20
+ constexpr allocator_type get_allocator() const; // constexpr since C++26
+ constexpr explicit operator bool() const noexcept; // constexpr since C++26
+ [[nodiscard]] constexpr bool empty() const noexcept; // nodiscard since C++20, constexpr since C++26
// [container.node.modifiers], modifiers
- void swap(node-handle&)
+ constexpr void swap(node-handle&)
noexcept(ator_traits::propagate_on_container_swap::value ||
- ator_traits::is_always_equal::value);
+ ator_traits::is_always_equal::value); // constexpr since C++26
- friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
+ constexpr friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) {
x.swap(y);
- }
+ } // constexpr since C++26
};
*/
@@ -99,12 +99,12 @@ private:
__node_pointer_type __ptr_ = nullptr;
optional<allocator_type> __alloc_;
- _LIBCPP_HIDE_FROM_ABI void __release_ptr() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __release_ptr() {
__ptr_ = nullptr;
__alloc_ = std::nullopt;
}
- _LIBCPP_HIDE_FROM_ABI void __destroy_node_pointer() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __destroy_node_pointer() {
if (__ptr_ != nullptr) {
typedef typename __allocator_traits_rebind< allocator_type, _NodeType>::type __node_alloc_type;
__node_alloc_type __alloc(*__alloc_);
@@ -113,19 +113,20 @@ private:
}
}
- _LIBCPP_HIDE_FROM_ABI __basic_node_handle(__node_pointer_type __ptr, allocator_type const& __alloc)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ __basic_node_handle(__node_pointer_type __ptr, allocator_type const& __alloc)
: __ptr_(__ptr), __alloc_(__alloc) {}
public:
- _LIBCPP_HIDE_FROM_ABI __basic_node_handle() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle() = default;
- _LIBCPP_HIDE_FROM_ABI __basic_node_handle(__basic_node_handle&& __other) noexcept
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle(__basic_node_handle&& __other) noexcept
: __ptr_(__other.__ptr_), __alloc_(std::move(__other.__alloc_)) {
__other.__ptr_ = nullptr;
__other.__alloc_ = std::nullopt;
}
- _LIBCPP_HIDE_FROM_ABI __basic_node_handle& operator=(__basic_node_handle&& __other) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __basic_node_handle& operator=(__basic_node_handle&& __other) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__alloc_ == std::nullopt || __alloc_traits::propagate_on_container_move_assignment::value ||
__alloc_ == __other.__alloc_,
@@ -144,13 +145,13 @@ public:
return *this;
}
- _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const { return *__alloc_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const { return *__alloc_; }
- _LIBCPP_HIDE_FROM_ABI explicit operator bool() const { return __ptr_ != nullptr; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit operator bool() const { return __ptr_ != nullptr; }
- [[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool empty() const { return __ptr_ == nullptr; }
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const { return __ptr_ == nullptr; }
- _LIBCPP_HIDE_FROM_ABI void swap(__basic_node_handle& __other) noexcept(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__basic_node_handle& __other) noexcept(
__alloc_traits::propagate_on_container_swap::value || __alloc_traits::is_always_equal::value) {
using std::swap;
swap(__ptr_, __other.__ptr_);
@@ -159,12 +160,12 @@ public:
swap(__alloc_, __other.__alloc_);
}
- _LIBCPP_HIDE_FROM_ABI friend void
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 friend void
swap(__basic_node_handle& __a, __basic_node_handle& __b) noexcept(noexcept(__a.swap(__b))) {
__a.swap(__b);
}
- _LIBCPP_HIDE_FROM_ABI ~__basic_node_handle() { __destroy_node_pointer(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__basic_node_handle() { __destroy_node_pointer(); }
};
template <class _NodeType, class _Derived>
@@ -179,6 +180,7 @@ struct __map_node_handle_specifics {
using key_type = __remove_const_t<typename _NodeType::__node_value_type::first_type>;
using mapped_type = typename _NodeType::__node_value_type::second_type;
+ // This method is not constexpr as per the standard.
_LIBCPP_HIDE_FROM_ABI key_type& key() const {
return const_cast<key_type&>(static_cast<_Derived const*>(this)->__ptr_->__get_value().first);
}
diff --git a/libcxx/include/__numeric/saturation_arithmetic.h b/libcxx/include/__numeric/saturation_arithmetic.h
index 4491bab2b1479..7a7410b5dea08 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -121,27 +121,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
#if _LIBCPP_STD_VER >= 26
template <__signed_or_unsigned_integer _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
return std::__add_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
return std::__sub_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
return std::__mul_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
return std::__div_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
return std::__saturate_cast<_Rp>(__x);
}
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 694796922c914..5398ff911ec57 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -28,6 +28,8 @@
#include <__type_traits/copy_cvref.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/invoke.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_constant_evaluated.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_nothrow_assignable.h>
#include <__type_traits/is_nothrow_constructible.h>
@@ -111,7 +113,7 @@ __root, have a non-null __parent_ field.
// Returns: true if __x is a left child of its parent, else false
// Precondition: __x != nullptr.
template <class _NodePtr>
-inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
return __x == __x->__parent_->__left_;
}
@@ -119,7 +121,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT {
// __x is a proper subtree, returns the black height (null counts as 1). If
// __x is an improper subtree, returns 0.
template <class _NodePtr>
-unsigned __tree_sub_invariant(_NodePtr __x) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 unsigned __tree_sub_invariant(_NodePtr __x) {
if (__x == nullptr)
return 1;
// parent consistency checked by caller
@@ -151,7 +153,7 @@ unsigned __tree_sub_invariant(_NodePtr __x) {
// __root == nullptr is a proper tree. Returns true if __root is a proper
// red black tree, else returns false.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __tree_invariant(_NodePtr __root) {
if (__root == nullptr)
return true;
// check __x->__parent_ consistency
@@ -168,7 +170,7 @@ _LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) {
// Returns: pointer to the left-most node under __x.
template <class _NodePtr>
-inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Root node shouldn't be null");
while (__x->__left_ != nullptr)
__x = __x->__left_;
@@ -177,7 +179,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT {
// Returns: pointer to the right-most node under __x.
template <class _NodePtr>
-inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Root node shouldn't be null");
while (__x->__right_ != nullptr)
__x = __x->__right_;
@@ -186,7 +188,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_max(_NodePtr __x) _NOEXCEPT {
// Returns: pointer to the next in-order node after __x.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
if (__x->__right_ != nullptr)
return std::__tree_min(__x->__right_);
@@ -201,23 +203,23 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
// to the actual root of the tree through a __left_ pointer. Incrementing the end() pointer is UB, so we can assume that
// never happens.
template <class _EndNodePtr, class _NodePtr>
-inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
if (__x->__right_ != nullptr)
- return static_cast<_EndNodePtr>(std::__tree_min(__x->__right_));
+ return std::__static_fancy_pointer_cast<_EndNodePtr>(std::__tree_min(__x->__right_));
while (!std::__tree_is_left_child(__x))
__x = __x->__parent_unsafe();
- return static_cast<_EndNodePtr>(__x->__parent_);
+ return std::__static_fancy_pointer_cast<_EndNodePtr>(__x->__parent_);
}
// Returns: pointer to the previous in-order node before __x.
// Note: __x may be the end node.
template <class _NodePtr, class _EndNodePtr>
-inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
if (__x->__left_ != nullptr)
return std::__tree_max(__x->__left_);
- _NodePtr __xx = static_cast<_NodePtr>(__x);
+ _NodePtr __xx = std::__static_fancy_pointer_cast<_NodePtr>(__x);
while (std::__tree_is_left_child(__xx))
__xx = __xx->__parent_unsafe();
return __xx->__parent_unsafe();
@@ -225,7 +227,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_prev_iter(_EndNodePtr __x) _NOEXCEP
// Returns: pointer to a node which has no children
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
while (true) {
if (__x->__left_ != nullptr) {
@@ -244,7 +246,7 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_leaf(_NodePtr __x) _NOEXCEPT {
// Effects: Makes __x->__right_ the subtree root with __x as its left child
// while preserving in-order order.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
_LIBCPP_ASSERT_INTERNAL(__x->__right_ != nullptr, "node should have a right child");
_NodePtr __y = __x->__right_;
@@ -263,7 +265,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT {
// Effects: Makes __x->__left_ the subtree root with __x as its right child
// while preserving in-order order.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
_LIBCPP_ASSERT_INTERNAL(__x->__left_ != nullptr, "node should have a left child");
_NodePtr __y = __x->__left_;
@@ -287,7 +289,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
// Postcondition: __tree_invariant(end_node->__left_) == true. end_node->__left_
// may be different than the value passed in as __root.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+__tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root of the tree shouldn't be null");
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Can't attach null node to a leaf");
__x->__is_black_ = __x == __root;
@@ -343,7 +346,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr
// nor any of its children refer to __z. end_node->__left_
// may be different than the value passed in as __root.
template <class _NodePtr>
-_LIBCPP_HIDE_FROM_ABI void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_remove(_NodePtr __root, _NodePtr __z) _NOEXCEPT {
_LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root node should not be null");
_LIBCPP_ASSERT_INTERNAL(__z != nullptr, "The node to remove should not be null");
_LIBCPP_ASSERT_INTERNAL(std::__tree_invariant(__root), "The tree invariants should hold");
@@ -558,7 +561,7 @@ public:
using pointer = _Pointer;
pointer __left_;
- _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_end_node() _NOEXCEPT : __left_(nullptr) {}
};
template <class _VoidPtr>
@@ -571,11 +574,15 @@ public:
__end_node_pointer __parent_;
bool __is_black_;
- _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast<pointer>(__parent_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer __parent_unsafe() const {
+ return std::__static_fancy_pointer_cast<pointer>(__parent_);
+ }
- _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__end_node_pointer>(__p); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set_parent(pointer __p) {
+ __parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__p);
+ }
- _LIBCPP_HIDE_FROM_ABI __tree_node_base() = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node_base() = default;
__tree_node_base(__tree_node_base const&) = delete;
__tree_node_base& operator=(__tree_node_base const&) = delete;
};
@@ -596,7 +603,7 @@ private:
};
public:
- _LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_value_type& __get_value() { return __value_; }
#else
private:
@@ -607,10 +614,24 @@ public:
#endif
template <class _Alloc, class... _Args>
- _LIBCPP_HIDE_FROM_ABI explicit __tree_node(_Alloc& __na, _Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node(_Alloc& __na, _Args&&... __args) {
allocator_traits<_Alloc>::construct(__na, std::addressof(__get_value()), std::forward<_Args>(__args)...);
}
+
+// This line fails with:
+// libcxx/test-suite-install/include/c++/v1/__memory/construct_at.h:38:49: note: non-literal type
+// `'std::__tree_node<std::__value_type<Key, int>, void *>' cannot be used in a constant expression`
+// during constant evaluation as part of P3372
+// on:
+// 1. AppleClang, which is not yet using clang >= 20.x, which has "fixed" this issue
+// FIXME: when AppleClang is based off of clang >= 20.x
+// FIXME: when Clang-based CI is using clang >= 20.x
+#if (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 2000) || \
+ (defined(_LIBCPP_APPLE_CLANG_VER) && _LIBCPP_APPLE_CLANG_VER < 2000)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__tree_node() {}
+#else
~__tree_node() = delete;
+#endif
__tree_node(__tree_node const&) = delete;
__tree_node& operator=(__tree_node const&) = delete;
};
@@ -629,14 +650,15 @@ private:
public:
bool __value_constructed;
- _LIBCPP_HIDE_FROM_ABI __tree_node_destructor(const __tree_node_destructor&) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node_destructor(const __tree_node_destructor&) = default;
__tree_node_destructor& operator=(const __tree_node_destructor&) = delete;
- _LIBCPP_HIDE_FROM_ABI explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node_destructor(allocator_type& __na, bool __val = false) _NOEXCEPT
: __na_(__na),
__value_constructed(__val) {}
- _LIBCPP_HIDE_FROM_ABI void operator()(pointer __p) _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(pointer __p) _NOEXCEPT {
if (__value_constructed)
__alloc_traits::destroy(__na_, std::addressof(__p->__get_value()));
if (__p)
@@ -673,44 +695,50 @@ public:
using reference = value_type&;
using pointer = __rebind_pointer_t<_NodePtr, value_type>;
- _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator() _NOEXCEPT : __ptr_(nullptr) {}
- _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); }
- _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __get_np()->__get_value(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
return pointer_traits<pointer>::pointer_to(__get_np()->__get_value());
}
- _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() {
- __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator++() {
+ __ptr_ = std::__tree_next_iter<__end_node_pointer>(std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr_));
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __tree_iterator operator++(int) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator operator++(int) {
__tree_iterator __t(*this);
++(*this);
return __t;
}
- _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator--() {
- __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator--() {
+ __ptr_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __tree_iterator operator--(int) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator operator--(int) {
__tree_iterator __t(*this);
--(*this);
return __t;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_iterator& __x, const __tree_iterator& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
+ operator==(const __tree_iterator& __x, const __tree_iterator& __y) {
return __x.__ptr_ == __y.__ptr_;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
+ operator!=(const __tree_iterator& __x, const __tree_iterator& __y) {
return !(__x == __y);
}
private:
- _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
- _LIBCPP_HIDE_FROM_ABI explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
- _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator(__node_pointer __p) _NOEXCEPT
+ : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT
+ : __ptr_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const {
+ return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_);
+ }
template <class, class, class>
friend class __tree;
template <class, class, class>
@@ -735,48 +763,55 @@ public:
using pointer = __rebind_pointer_t<_NodePtr, const value_type>;
using __non_const_iterator _LIBCPP_NODEBUG = __tree_iterator<_Tp, __node_pointer, difference_type>;
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator() _NOEXCEPT : __ptr_(nullptr) {}
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT : __ptr_(__p.__ptr_) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator(__non_const_iterator __p) _NOEXCEPT
+ : __ptr_(__p.__ptr_) {}
- _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__get_value(); }
- _LIBCPP_HIDE_FROM_ABI pointer operator->() const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __get_np()->__get_value(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
return pointer_traits<pointer>::pointer_to(__get_np()->__get_value());
}
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() {
- __ptr_ = std::__tree_next_iter<__end_node_pointer>(static_cast<__node_base_pointer>(__ptr_));
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator++() {
+ __ptr_ = std::__tree_next_iter<__end_node_pointer>(std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr_));
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator++(int) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator operator++(int) {
__tree_const_iterator __t(*this);
++(*this);
return __t;
}
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator--() {
- __ptr_ = static_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator--() {
+ __ptr_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
return *this;
}
- _LIBCPP_HIDE_FROM_ABI __tree_const_iterator operator--(int) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator operator--(int) {
__tree_const_iterator __t(*this);
--(*this);
return __t;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
+ operator==(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
return __x.__ptr_ == __y.__ptr_;
}
- friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
+ friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
+ operator!=(const __tree_const_iterator& __x, const __tree_const_iterator& __y) {
return !(__x == __y);
}
private:
- _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
- _LIBCPP_HIDE_FROM_ABI explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}
- _LIBCPP_HIDE_FROM_ABI __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT
+ : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT
+ : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>(__p)) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const {
+ return std::__static_fancy_pointer_cast<__node_pointer>(__ptr_);
+ }
template <class, class, class>
friend class __tree;
@@ -840,63 +875,73 @@ private:
_LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_);
public:
- _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer __end_node() _NOEXCEPT {
return pointer_traits<__end_node_pointer>::pointer_to(__end_node_);
}
- _LIBCPP_HIDE_FROM_ABI __end_node_pointer __end_node() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer __end_node() const _NOEXCEPT {
return pointer_traits<__end_node_pointer>::pointer_to(const_cast<__end_node_t&>(__end_node_));
}
- _LIBCPP_HIDE_FROM_ABI __node_allocator& __node_alloc() _NOEXCEPT { return __node_alloc_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_allocator& __node_alloc() _NOEXCEPT {
+ return __node_alloc_;
+ }
private:
- _LIBCPP_HIDE_FROM_ABI const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const __node_allocator& __node_alloc() const _NOEXCEPT {
+ return __node_alloc_;
+ }
public:
- _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type __alloc() const _NOEXCEPT {
+ return allocator_type(__node_alloc());
+ }
- _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __size_; }
- _LIBCPP_HIDE_FROM_ABI value_compare& value_comp() _NOEXCEPT { return __value_comp_; }
- _LIBCPP_HIDE_FROM_ABI const value_compare& value_comp() const _NOEXCEPT { return __value_comp_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT { return __size_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare& value_comp() _NOEXCEPT { return __value_comp_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const value_compare& value_comp() const _NOEXCEPT {
+ return __value_comp_;
+ }
public:
- _LIBCPP_HIDE_FROM_ABI __node_pointer __root() const _NOEXCEPT {
- return static_cast<__node_pointer>(__end_node()->__left_);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __root() const _NOEXCEPT {
+ return std::__static_fancy_pointer_cast<__node_pointer>(__end_node()->__left_);
}
- _LIBCPP_HIDE_FROM_ABI __node_base_pointer* __root_ptr() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer* __root_ptr() const _NOEXCEPT {
return std::addressof(__end_node()->__left_);
}
using iterator = __tree_iterator<_Tp, __node_pointer, difference_type>;
using const_iterator = __tree_const_iterator<_Tp, __node_pointer, difference_type>;
- _LIBCPP_HIDE_FROM_ABI explicit __tree(const value_compare& __comp) _NOEXCEPT_(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree(const value_compare& __comp) _NOEXCEPT_(
is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible<value_compare>::value)
: __size_(0), __value_comp_(__comp) {
__begin_node_ = __end_node();
}
- _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree(const allocator_type& __a)
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0) {
__begin_node_ = __end_node();
}
- _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const value_compare& __comp, const allocator_type& __a)
: __begin_node_(), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) {
__begin_node_ = __end_node();
}
- _LIBCPP_HIDE_FROM_ABI __tree(const __tree& __t);
- _LIBCPP_HIDE_FROM_ABI __tree& operator=(const __tree& __t);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const __tree& __t);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree& operator=(const __tree& __t);
template <class _ForwardIterator>
- _LIBCPP_HIDE_FROM_ABI void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
template <class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI void __assign_multi(_InputIterator __first, _InputIterator __last);
- _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t) _NOEXCEPT_(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __assign_multi(_InputIterator __first, _InputIterator __last);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(__tree&& __t) _NOEXCEPT_(
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value);
- _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(__tree&& __t, const allocator_type& __a);
- _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree& operator=(__tree&& __t)
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value &&
((__node_traits::propagate_on_container_move_assignment::value &&
is_nothrow_move_assignable<__node_allocator>::value) ||
@@ -905,23 +950,27 @@ public:
return *this;
}
- _LIBCPP_HIDE_FROM_ABI ~__tree() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__tree() {
static_assert(is_copy_constructible<value_compare>::value, "Comparator must be copy-constructible.");
destroy(__root());
}
- _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
- _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(__begin_node_); }
- _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(__end_node()); }
- _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(__end_node()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT { return iterator(__begin_node_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT {
+ return const_iterator(__begin_node_);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT { return iterator(__end_node()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT {
+ return const_iterator(__end_node());
+ }
- _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
return std::min<size_type>(__node_traits::max_size(__node_alloc()), numeric_limits<difference_type >::max());
}
- _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI void swap(__tree& __t)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__tree& __t)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>));
@@ -930,21 +979,22 @@ public:
#endif
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_multi(_Args&&... __args);
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_multi(const_iterator __p, _Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
+ __emplace_hint_multi(const_iterator __p, _Args&&... __args);
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_unique(_Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> __emplace_unique(_Args&&... __args) {
return std::__try_key_extraction<key_type>(
[this](const key_type& __key, _Args&&... __args2) {
auto [__parent, __child] = __find_equal(__key);
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
bool __inserted = false;
if (__child == nullptr) {
__node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
__inserted = true;
}
@@ -953,10 +1003,10 @@ public:
[this](_Args&&... __args2) {
__node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
auto [__parent, __child] = __find_equal(__h->__get_value());
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
bool __inserted = false;
if (__child == nullptr) {
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
__inserted = true;
}
@@ -966,16 +1016,17 @@ public:
}
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
+ __emplace_hint_unique(const_iterator __p, _Args&&... __args) {
return std::__try_key_extraction<key_type>(
[this, __p](const key_type& __key, _Args&&... __args2) {
__node_base_pointer __dummy;
auto [__parent, __child] = __find_equal(__p, __dummy, __key);
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
bool __inserted = false;
if (__child == nullptr) {
__node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
__inserted = true;
}
@@ -985,9 +1036,9 @@ public:
__node_holder __h = __construct_node(std::forward<_Args>(__args2)...);
__node_base_pointer __dummy;
auto [__parent, __child] = __find_equal(__p, __dummy, __h->__get_value());
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
if (__child == nullptr) {
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
__r = __h.release();
}
return pair<iterator, bool>(iterator(__r), __child == nullptr);
@@ -995,73 +1046,112 @@ public:
std::forward<_Args>(__args)...);
}
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
+ __emplace_hint_unique__sfinae(true_type, const_iterator __p, _Args&&... __args) {
+ return __emplace_hint_unique(__p, __args...);
+ }
+
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
+ __emplace_hint_unique__sfinae(false_type, const_iterator, _Args&&...) {
+ // This method body should never be run. It only exists to allow for compilation. See note in
+ // __insert_unique_from_orphaned_node for more information.
+ return pair<iterator, bool>(iterator(__node_pointer()), false);
+ }
+
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI void
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
__insert_unique_from_orphaned_node(const_iterator __p, __get_node_value_type_t<_Tp>&& __value) {
- __emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
+#if _LIBCPP_STD_VER >= 26
+ if (std::is_constant_evaluated() && std::is_copy_constructible_v<decltype(__value.first)>) {
+ // We create a sfinae wrapper method here, because if the __emplace_hint_unique method gets template instantiated
+ // within __insert_unique_from_orphaned_node, the code will fail to compile when the value is not
+ // copy_constructible (even for runtime execution); unless we use `if constexpr`. Given the copy-constructible
+ // code path will be a performance regression, we want to restrict it to only execute during constant evaluation
+ // , hence, we need to delay the template instantiation.
+ __emplace_hint_unique__sfinae(
+ integral_constant< bool, std::is_copy_constructible_v<decltype(__value.first)> >(),
+ __p,
+ __value.first,
+ std::move(__value.second));
+ } else
+#endif
+ {
+ __emplace_hint_unique(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
+ }
}
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI void __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __insert_unique_from_orphaned_node(const_iterator __p, _Tp&& __value) {
__emplace_hint_unique(__p, std::move(__value));
}
template <class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __insert_multi_from_orphaned_node(const_iterator __p, value_type&& __value) {
__emplace_hint_multi(__p, const_cast<key_type&&>(__value.first), std::move(__value.second));
}
template <class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI void __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __insert_multi_from_orphaned_node(const_iterator __p, _Tp&& __value) {
__emplace_hint_multi(__p, std::move(__value));
}
template <class _InIter, class _Sent>
- _LIBCPP_HIDE_FROM_ABI void __insert_range_multi(_InIter __first, _Sent __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_range_multi(_InIter __first, _Sent __last) {
if (__first == __last)
return;
if (__root() == nullptr) { // Make sure we always have a root node
- __insert_node_at(
- __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release()));
+ __insert_node_at(__end_node(),
+ __end_node()->__left_,
+ std::__static_fancy_pointer_cast<__node_base_pointer>(__construct_node(*__first).release()));
++__first;
}
- auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root())));
+ auto __max_node = std::__static_fancy_pointer_cast<__node_pointer>(
+ std::__tree_max(std::__static_fancy_pointer_cast<__node_base_pointer>(__root())));
for (; __first != __last; ++__first) {
__node_holder __nd = __construct_node(*__first);
// Always check the max node first. This optimizes for sorted ranges inserted at the end.
if (!value_comp()(__nd->__get_value(), __max_node->__get_value())) { // __node >= __max_val
- __insert_node_at(static_cast<__end_node_pointer>(__max_node),
+ __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
__max_node->__right_,
- static_cast<__node_base_pointer>(__nd.get()));
+ std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
__max_node = __nd.release();
} else {
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf_high(__parent, __nd->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
}
}
}
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> __node_assign_unique(const value_type& __v, __node_pointer __dest);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
+ __node_assign_unique(const value_type& __v, __node_pointer __dest);
- _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd);
- _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(const_iterator __p, __node_pointer __nd);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __node_insert_multi(__node_pointer __nd);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
+ __node_insert_multi(const_iterator __p, __node_pointer __nd);
template <class _InIter, class _Sent>
- _LIBCPP_HIDE_FROM_ABI void __insert_range_unique(_InIter __first, _Sent __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_range_unique(_InIter __first, _Sent __last) {
if (__first == __last)
return;
if (__root() == nullptr) {
- __insert_node_at(
- __end_node(), __end_node()->__left_, static_cast<__node_base_pointer>(__construct_node(*__first).release()));
+ __insert_node_at(__end_node(),
+ __end_node()->__left_,
+ std::__static_fancy_pointer_cast<__node_base_pointer>(__construct_node(*__first).release()));
++__first;
}
- auto __max_node = static_cast<__node_pointer>(std::__tree_max(static_cast<__node_base_pointer>(__root())));
+ auto __max_node = std::__static_fancy_pointer_cast<__node_pointer>(
+ std::__tree_max(std::__static_fancy_pointer_cast<__node_base_pointer>(__root())));
using __reference = decltype(*__first);
@@ -1070,29 +1160,31 @@ public:
[this, &__max_node](const key_type& __key, __reference&& __val) {
if (value_comp()(__max_node->__get_value(), __key)) { // __key > __max_node
__node_holder __nd = __construct_node(std::forward<__reference>(__val));
- __insert_node_at(static_cast<__end_node_pointer>(__max_node),
+ __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
__max_node->__right_,
- static_cast<__node_base_pointer>(__nd.get()));
+ std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
__max_node = __nd.release();
} else {
auto [__parent, __child] = __find_equal(__key);
if (__child == nullptr) {
__node_holder __nd = __construct_node(std::forward<__reference>(__val));
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
+ __insert_node_at(
+ __parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
}
}
},
[this, &__max_node](__reference&& __val) {
__node_holder __nd = __construct_node(std::forward<__reference>(__val));
if (value_comp()(__max_node->__get_value(), __nd->__get_value())) { // __node > __max_node
- __insert_node_at(static_cast<__end_node_pointer>(__max_node),
+ __insert_node_at(std::__static_fancy_pointer_cast<__end_node_pointer>(__max_node),
__max_node->__right_,
- static_cast<__node_base_pointer>(__nd.get()));
+ std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.get()));
__max_node = __nd.release();
} else {
auto [__parent, __child] = __find_equal(__nd->__get_value());
if (__child == nullptr) {
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd.release()));
+ __insert_node_at(
+ __parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd.release()));
}
}
},
@@ -1100,62 +1192,67 @@ public:
}
}
- _LIBCPP_HIDE_FROM_ABI iterator __remove_node_pointer(__node_pointer) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __remove_node_pointer(__node_pointer) _NOEXCEPT;
#if _LIBCPP_STD_VER >= 17
template <class _NodeHandle, class _InsertReturnType>
- _LIBCPP_HIDE_FROM_ABI _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _InsertReturnType __node_handle_insert_unique(_NodeHandle&&);
template <class _NodeHandle>
- _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_unique(const_iterator, _NodeHandle&&);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
+ __node_handle_insert_unique(const_iterator, _NodeHandle&&);
template <class _Comp2>
- _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source);
template <class _NodeHandle>
- _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(_NodeHandle&&);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __node_handle_insert_multi(_NodeHandle&&);
template <class _NodeHandle>
- _LIBCPP_HIDE_FROM_ABI iterator __node_handle_insert_multi(const_iterator, _NodeHandle&&);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
+ __node_handle_insert_multi(const_iterator, _NodeHandle&&);
template <class _Comp2>
- _LIBCPP_HIDE_FROM_ABI void __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source);
template <class _NodeHandle>
- _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(key_type const&);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle __node_handle_extract(key_type const&);
template <class _NodeHandle>
- _LIBCPP_HIDE_FROM_ABI _NodeHandle __node_handle_extract(const_iterator);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle __node_handle_extract(const_iterator);
#endif
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p);
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI size_type __erase_unique(const _Key& __k);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __erase_unique(const _Key& __k);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __erase_multi(const _Key& __k);
- _LIBCPP_HIDE_FROM_ABI void
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
__insert_node_at(__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator find(const _Key& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _Key& __key) {
auto [__, __match] = __find_equal(__key);
if (__match == nullptr)
return end();
- return iterator(static_cast<__node_pointer>(__match));
+ return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator find(const _Key& __key) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _Key& __key) const {
auto [__, __match] = __find_equal(__key);
if (__match == nullptr)
return end();
- return const_iterator(static_cast<__node_pointer>(__match));
+ return const_iterator(std::__static_fancy_pointer_cast<__node_pointer>(__match));
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI size_type __count_unique(const _Key& __k) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __count_unique(const _Key& __k) const;
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI size_type __count_multi(const _Key& __k) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type __count_multi(const _Key& __k) const;
template <bool _LowerBound, class _Key>
- _LIBCPP_HIDE_FROM_ABI __end_node_pointer __lower_upper_bound_unique_impl(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __end_node_pointer
+ __lower_upper_bound_unique_impl(const _Key& __v) const {
auto __rt = __root();
auto __result = __end_node();
auto __comp = __lazy_synth_three_way_comparator<_Compare, _Key, value_type>(value_comp());
@@ -1163,156 +1260,210 @@ public:
auto __comp_res = __comp(__v, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater()) {
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
} else if _LIBCPP_CONSTEXPR (_LowerBound) {
- return static_cast<__end_node_pointer>(__rt);
+ return std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
} else {
- return __rt->__right_ ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result;
+ return __rt->__right_ ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
+ : __result;
}
}
return __result;
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_unique(const _Key& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __lower_bound_unique(const _Key& __v) {
return iterator(__lower_upper_bound_unique_impl<true>(__v));
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_unique(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __lower_bound_unique(const _Key& __v) const {
return const_iterator(__lower_upper_bound_unique_impl<true>(__v));
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_unique(const _Key& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __upper_bound_unique(const _Key& __v) {
return iterator(__lower_upper_bound_unique_impl<false>(__v));
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_unique(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __upper_bound_unique(const _Key& __v) const {
return iterator(__lower_upper_bound_unique_impl<false>(__v));
}
private:
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
__lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
__lower_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
public:
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator __lower_bound_multi(const _Key& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __lower_bound_multi(const _Key& __v) {
return __lower_bound_multi(__v, __root(), __end_node());
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator __lower_bound_multi(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __lower_bound_multi(const _Key& __v) const {
return __lower_bound_multi(__v, __root(), __end_node());
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator __upper_bound_multi(const _Key& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __upper_bound_multi(const _Key& __v) {
return __upper_bound_multi(__v, __root(), __end_node());
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator __upper_bound_multi(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator __upper_bound_multi(const _Key& __v) const {
return __upper_bound_multi(__v, __root(), __end_node());
}
private:
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI iterator
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator
__upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI const_iterator
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator
__upper_bound_multi(const _Key& __v, __node_pointer __root, __end_node_pointer __result) const;
public:
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_unique(const _Key& __k);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> __equal_range_unique(const _Key& __k);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_unique(const _Key& __k) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ __equal_range_unique(const _Key& __k) const;
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> __equal_range_multi(const _Key& __k);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> __equal_range_multi(const _Key& __k);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> __equal_range_multi(const _Key& __k) const;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ __equal_range_multi(const _Key& __k) const;
using _Dp _LIBCPP_NODEBUG = __tree_node_destructor<__node_allocator>;
using __node_holder _LIBCPP_NODEBUG = unique_ptr<__node, _Dp>;
- _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_holder remove(const_iterator __p) _NOEXCEPT;
// FIXME: Make this function const qualified. Unfortunately doing so
// breaks existing code which uses non-const callable comparators.
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
+ __find_equal(const _Key& __v);
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&> __find_equal(const _Key& __v) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
+ __find_equal(const _Key& __v) const {
return const_cast<__tree*>(this)->__find_equal(__v);
}
template <class _Key>
- _LIBCPP_HIDE_FROM_ABI pair<__end_node_pointer, __node_base_pointer&>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<__end_node_pointer, __node_base_pointer&>
__find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v);
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree& __t) {
__copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());
}
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t, true_type) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree& __t, true_type) {
if (__node_alloc() != __t.__node_alloc())
clear();
__node_alloc() = __t.__node_alloc();
}
- _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __copy_assign_alloc(const __tree&, false_type) {}
private:
- _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__end_node_pointer& __parent, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
+ __find_leaf_low(__end_node_pointer& __parent, const value_type& __v);
- _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__end_node_pointer& __parent, const value_type& __v);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
+ __find_leaf_high(__end_node_pointer& __parent, const value_type& __v);
- _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer&
__find_leaf(const_iterator __hint, __end_node_pointer& __parent, const value_type& __v);
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_holder __construct_node(_Args&&... __args);
// TODO: Make this _LIBCPP_HIDE_FROM_ABI
- _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT { (__tree_deleter(__node_alloc_))(__nd); }
+ _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX26 void destroy(__node_pointer __nd) _NOEXCEPT {
+ (__tree_deleter(__node_alloc_))(__nd);
+ }
- _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
- _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign(__tree& __t, false_type);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree& __t)
_NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
is_nothrow_move_assignable<__node_allocator>::value) {
__move_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_move_assignment::value>());
}
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree& __t, true_type)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree& __t, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
__node_alloc() = std::move(__t.__node_alloc());
}
- _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
+
+ template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __assign_value__sfinae(true_type, __get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
+ __node_allocator& __na = __node_alloc();
+ __node_traits::destroy(__na, std::addressof(__lhs));
+ __node_traits::construct(__na, std::addressof(__lhs), __rhs.first, __rhs.second);
+ }
+
+ template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __assign_value__sfinae(false_type, __get_node_value_type_t<value_type>&, _From&&) {
+ // This method body should never be run. It only exists to allow for compilation. See note in __assign_value for
+ // more information.
+ }
template <class _From, class _ValueT = _Tp, __enable_if_t<__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI static void __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ __assign_value(__get_node_value_type_t<value_type>& __lhs, _From&& __rhs) {
using __key_type = __remove_const_t<typename value_type::first_type>;
- // This is technically UB, since the object was constructed as `const`.
- // Clang doesn't optimize on this currently though.
- const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
- __lhs.second = std::forward<_From>(__rhs).second;
+#if _LIBCPP_STD_VER >= 26
+
+ if (std::is_constant_evaluated() && std::is_copy_constructible_v<decltype(__rhs.first)>) {
+ // We use copy, and not "move" as the constraint here because we can NOT move
+ // from `const key_type`, which is how `value_type` is defined for `std::map`
+ // `typedef pair<const key_type, mapped_type> value_type;`
+ // so we must copy it to not perform undefined behavior which
+ // is disallowed during constant evaluation.
+
+ // Furthermore, `const_cast` is not allowed during constant evaluation.
+ // We get around this by deleting `__lhs` and creating a new node in-place
+ // to avoid the `const_cast` when attempting to assign to `__lhs.first`.
+
+ // We create a sfinae wrapper method here, because if the body of the `true_type` overload for
+ // `__assign_value__sfinae()` gets template instantiated within `__assign_value`,
+ // the code will fail to compile when
+ // the value is not copy_constructible (even for runtime execution); unless we use `if constexpr`.
+ // Given that the copy-constructible code path will be a performance regression,
+ // we want to restrict it to only execute during constant evaluation
+ //, we need to delay the template instantiation.
+
+ __assign_value__sfinae(std::integral_constant<bool, std::is_copy_constructible_v<decltype(__rhs.first)>>(),
+ std::forward<decltype(__lhs)>(__lhs),
+ std::forward<decltype(__rhs)>(__rhs));
+
+ } else
+#endif
+ {
+ // This is technically UB, since the object was constructed as `const`.
+ // Clang doesn't optimize on this currently though.
+ const_cast<__key_type&>(__lhs.first) = const_cast<__copy_cvref_t<_From, __key_type>&&>(__rhs.first);
+ __lhs.second = std::forward<_From>(__rhs).second;
+ }
}
template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
@@ -1321,26 +1472,26 @@ private:
}
struct _DetachedTreeCache {
- _LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT
: __t_(__t),
__cache_root_(__detach_from_tree(__t)) {
__advance();
}
- _LIBCPP_HIDE_FROM_ABI __node_pointer __get() const _NOEXCEPT { return __cache_elem_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get() const _NOEXCEPT { return __cache_elem_; }
- _LIBCPP_HIDE_FROM_ABI void __advance() _NOEXCEPT {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __advance() _NOEXCEPT {
__cache_elem_ = __cache_root_;
if (__cache_root_) {
__cache_root_ = __detach_next(__cache_root_);
}
}
- _LIBCPP_HIDE_FROM_ABI ~_DetachedTreeCache() {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~_DetachedTreeCache() {
__t_->destroy(__cache_elem_);
if (__cache_root_) {
while (__cache_root_->__parent_ != nullptr)
- __cache_root_ = static_cast<__node_pointer>(__cache_root_->__parent_);
+ __cache_root_ = std::__static_fancy_pointer_cast<__node_pointer>(__cache_root_->__parent_);
__t_->destroy(__cache_root_);
}
}
@@ -1349,8 +1500,8 @@ private:
_DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete;
private:
- _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT;
- _LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
__tree* __t_;
__node_pointer __cache_root_;
@@ -1363,24 +1514,23 @@ private:
public:
using pointer = __node_pointer;
- _LIBCPP_HIDE_FROM_ABI __tree_deleter(__node_allocator& __alloc) : __alloc_(__alloc) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_deleter(__node_allocator& __alloc) : __alloc_(__alloc) {}
#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
_LIBCPP_HIDE_FROM_ABI
#endif
- void
- operator()(__node_pointer __ptr) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 void operator()(__node_pointer __ptr) {
if (!__ptr)
return;
- (*this)(static_cast<__node_pointer>(__ptr->__left_));
+ (*this)(std::__static_fancy_pointer_cast<__node_pointer>(__ptr->__left_));
auto __right = __ptr->__right_;
__node_traits::destroy(__alloc_, std::addressof(__ptr->__get_value()));
__node_traits::deallocate(__alloc_, __ptr, 1);
- (*this)(static_cast<__node_pointer>(__right));
+ (*this)(std::__static_fancy_pointer_cast<__node_pointer>(__right));
}
};
@@ -1391,26 +1541,25 @@ private:
#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
_LIBCPP_HIDE_FROM_ABI
#endif
- __node_pointer
- __copy_construct_tree(__node_pointer __src) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __copy_construct_tree(__node_pointer __src) {
if (!__src)
return nullptr;
__node_holder __new_node = __construct_node(__src->__get_value());
unique_ptr<__node, __tree_deleter> __left(
- __copy_construct_tree(static_cast<__node_pointer>(__src->__left_)), __node_alloc_);
- __node_pointer __right = __copy_construct_tree(static_cast<__node_pointer>(__src->__right_));
+ __copy_construct_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_)), __node_alloc_);
+ __node_pointer __right = __copy_construct_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_));
__node_pointer __new_node_ptr = __new_node.release();
__new_node_ptr->__is_black_ = __src->__is_black_;
- __new_node_ptr->__left_ = static_cast<__node_base_pointer>(__left.release());
- __new_node_ptr->__right_ = static_cast<__node_base_pointer>(__right);
+ __new_node_ptr->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__left.release());
+ __new_node_ptr->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__right);
if (__new_node_ptr->__left_)
- __new_node_ptr->__left_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr);
+ __new_node_ptr->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__new_node_ptr);
if (__new_node_ptr->__right_)
- __new_node_ptr->__right_->__parent_ = static_cast<__end_node_pointer>(__new_node_ptr);
+ __new_node_ptr->__right_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__new_node_ptr);
return __new_node_ptr;
}
@@ -1420,8 +1569,7 @@ private:
#ifdef _LIBCPP_COMPILER_CLANG_BASED // FIXME: GCC complains about not being able to always_inline a recursive function
_LIBCPP_HIDE_FROM_ABI
#endif
- __node_pointer
- __copy_assign_tree(__node_pointer __dest, __node_pointer __src) {
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __copy_assign_tree(__node_pointer __dest, __node_pointer __src) {
if (!__src) {
destroy(__dest);
return nullptr;
@@ -1432,24 +1580,26 @@ private:
// If we already have a left node in the destination tree, reuse it and copy-assign recursively
if (__dest->__left_) {
- __dest->__left_ = static_cast<__node_base_pointer>(__copy_assign_tree(
- static_cast<__node_pointer>(__dest->__left_), static_cast<__node_pointer>(__src->__left_)));
+ __dest->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_assign_tree(
+ std::__static_fancy_pointer_cast<__node_pointer>(__dest->__left_),
+ std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_)));
// Otherwise, we must create new nodes; copy-construct from here on
} else if (__src->__left_) {
- auto __new_left = __copy_construct_tree(static_cast<__node_pointer>(__src->__left_));
- __dest->__left_ = static_cast<__node_base_pointer>(__new_left);
- __new_left->__parent_ = static_cast<__end_node_pointer>(__dest);
+ auto __new_left = __copy_construct_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__left_));
+ __dest->__left_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__new_left);
+ __new_left->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__dest);
}
// Identical to the left case above, just for the right nodes
if (__dest->__right_) {
- __dest->__right_ = static_cast<__node_base_pointer>(__copy_assign_tree(
- static_cast<__node_pointer>(__dest->__right_), static_cast<__node_pointer>(__src->__right_)));
+ __dest->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_assign_tree(
+ std::__static_fancy_pointer_cast<__node_pointer>(__dest->__right_),
+ std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_)));
} else if (__src->__right_) {
- auto __new_right = __copy_construct_tree(static_cast<__node_pointer>(__src->__right_));
- __dest->__right_ = static_cast<__node_base_pointer>(__new_right);
- __new_right->__parent_ = static_cast<__end_node_pointer>(__dest);
+ auto __new_right = __copy_construct_tree(std::__static_fancy_pointer_cast<__node_pointer>(__src->__right_));
+ __dest->__right_ = std::__static_fancy_pointer_cast<__node_base_pointer>(__new_right);
+ __new_right->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__dest);
}
return __dest;
@@ -1458,16 +1608,16 @@ private:
// Precondition: __size_ != 0
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree* __t) _NOEXCEPT {
- __node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node_);
+ __node_pointer __cache = std::__static_fancy_pointer_cast<__node_pointer>(__t->__begin_node_);
__t->__begin_node_ = __t->__end_node();
__t->__end_node()->__left_->__parent_ = nullptr;
__t->__end_node()->__left_ = nullptr;
__t->__size_ = 0;
// __cache->__left_ == nullptr
if (__cache->__right_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__right_);
+ __cache = std::__static_fancy_pointer_cast<__node_pointer>(__cache->__right_);
// __cache->__left_ == nullptr
// __cache->__right_ == nullptr
return __cache;
@@ -1478,27 +1628,28 @@ __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree
// __cache->right_ == nullptr
// This is no longer a red-black tree
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT {
if (__cache->__parent_ == nullptr)
return nullptr;
- if (std::__tree_is_left_child(static_cast<__node_base_pointer>(__cache))) {
+ if (std::__tree_is_left_child(std::__static_fancy_pointer_cast<__node_base_pointer>(__cache))) {
__cache->__parent_->__left_ = nullptr;
- __cache = static_cast<__node_pointer>(__cache->__parent_);
+ __cache = std::__static_fancy_pointer_cast<__node_pointer>(__cache->__parent_);
if (__cache->__right_ == nullptr)
return __cache;
- return static_cast<__node_pointer>(std::__tree_leaf(__cache->__right_));
+ return std::__static_fancy_pointer_cast<__node_pointer>(std::__tree_leaf(__cache->__right_));
}
// __cache is right child
__cache->__parent_unsafe()->__right_ = nullptr;
- __cache = static_cast<__node_pointer>(__cache->__parent_);
+ __cache = std::__static_fancy_pointer_cast<__node_pointer>(__cache->__parent_);
if (__cache->__left_ == nullptr)
return __cache;
- return static_cast<__node_pointer>(std::__tree_leaf(__cache->__left_));
+ return std::__static_fancy_pointer_cast<__node_pointer>(std::__tree_leaf(__cache->__left_));
}
template <class _Tp, class _Compare, class _Allocator>
-__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>&
+__tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t) {
if (this == std::addressof(__t))
return *this;
@@ -1506,14 +1657,15 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
__copy_assign_alloc(__t);
if (__size_ != 0) {
- *__root_ptr() = static_cast<__node_base_pointer>(__copy_assign_tree(__root(), __t.__root()));
+ *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_assign_tree(__root(), __t.__root()));
} else {
- *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
+ *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
if (__root())
__root()->__parent_ = __end_node();
}
- __begin_node_ =
- __end_node()->__left_ ? static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_)) : __end_node();
+ __begin_node_ = __end_node()->__left_
+ ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_))
+ : __end_node();
__size_ = __t.size();
return *this;
@@ -1521,7 +1673,8 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(
template <class _Tp, class _Compare, class _Allocator>
template <class _ForwardIterator>
-void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void
+__tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last) {
using _ITraits = iterator_traits<_ForwardIterator>;
using _ItValueType = typename _ITraits::value_type;
static_assert(
@@ -1541,7 +1694,8 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first
template <class _Tp, class _Compare, class _Allocator>
template <class _InputIterator>
-void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void
+__tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _InputIterator __last) {
using _ITraits = iterator_traits<_InputIterator>;
using _ItValueType = typename _ITraits::value_type;
static_assert(
@@ -1560,7 +1714,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _
}
template <class _Tp, class _Compare, class _Allocator>
-__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
: __begin_node_(__end_node()),
__node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())),
__size_(0),
@@ -1568,14 +1722,14 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t)
if (__t.size() == 0)
return;
- *__root_ptr() = static_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
+ *__root_ptr() = std::__static_fancy_pointer_cast<__node_base_pointer>(__copy_construct_tree(__t.__root()));
__root()->__parent_ = __end_node();
- __begin_node_ = static_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
+ __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__end_node()->__left_));
__size_ = __t.size();
}
template <class _Tp, class _Compare, class _Allocator>
-__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
is_nothrow_move_constructible<__node_allocator>::value&& is_nothrow_move_constructible<value_compare>::value)
: __begin_node_(std::move(__t.__begin_node_)),
__end_node_(std::move(__t.__end_node_)),
@@ -1585,7 +1739,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
if (__size_ == 0)
__begin_node_ = __end_node();
else {
- __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
+ __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
__t.__begin_node_ = __t.__end_node();
__t.__end_node()->__left_ = nullptr;
__t.__size_ = 0;
@@ -1593,7 +1747,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_(
}
template <class _Tp, class _Compare, class _Allocator>
-__tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __a)
: __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(std::move(__t.value_comp())) {
if (__a == __t.__alloc()) {
if (__t.__size_ == 0)
@@ -1601,7 +1755,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __
else {
__begin_node_ = __t.__begin_node_;
__end_node()->__left_ = __t.__end_node()->__left_;
- __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
+ __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
__size_ = __t.__size_;
__t.__begin_node_ = __t.__end_node();
__t.__end_node()->__left_ = nullptr;
@@ -1613,9 +1767,9 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t, const allocator_type& __
}
template <class _Tp, class _Compare, class _Allocator>
-void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
_NOEXCEPT_(is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value) {
- destroy(static_cast<__node_pointer>(__end_node()->__left_));
+ destroy(std::__static_fancy_pointer_cast<__node_pointer>(__end_node()->__left_));
__begin_node_ = __t.__begin_node_;
__end_node_ = __t.__end_node_;
__move_assign_alloc(__t);
@@ -1624,7 +1778,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
if (__size_ == 0)
__begin_node_ = __end_node();
else {
- __end_node()->__left_->__parent_ = static_cast<__end_node_pointer>(__end_node());
+ __end_node()->__left_->__parent_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__end_node());
__t.__begin_node_ = __t.__end_node();
__t.__end_node()->__left_ = nullptr;
__t.__size_ = 0;
@@ -1632,7 +1786,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, true_type)
}
template <class _Tp, class _Compare, class _Allocator>
-void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
if (__node_alloc() == __t.__node_alloc())
__move_assign(__t, true_type());
else {
@@ -1653,7 +1807,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) {
}
template <class _Tp, class _Compare, class _Allocator>
-void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
#if _LIBCPP_STD_VER <= 11
_NOEXCEPT_(__is_nothrow_swappable_v<value_compare> &&
(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>))
@@ -1678,7 +1832,7 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t)
}
template <class _Tp, class _Compare, class _Allocator>
-void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
destroy(__root());
__size_ = 0;
__begin_node_ = __end_node();
@@ -1689,23 +1843,23 @@ void __tree<_Tp, _Compare, _Allocator>::clear() _NOEXCEPT {
// Set __parent to parent of null leaf
// Return reference to null leaf
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
__tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent, const value_type& __v) {
__node_pointer __nd = __root();
if (__nd != nullptr) {
while (true) {
if (value_comp()(__nd->__get_value(), __v)) {
if (__nd->__right_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__right_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
else {
- __parent = static_cast<__end_node_pointer>(__nd);
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
return __nd->__right_;
}
} else {
if (__nd->__left_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__left_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
else {
- __parent = static_cast<__end_node_pointer>(__nd);
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
return __parent->__left_;
}
}
@@ -1719,23 +1873,23 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_low(__end_node_pointer& __parent,
// Set __parent to parent of null leaf
// Return reference to null leaf
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
__tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent, const value_type& __v) {
__node_pointer __nd = __root();
if (__nd != nullptr) {
while (true) {
if (value_comp()(__v, __nd->__get_value())) {
if (__nd->__left_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__left_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
else {
- __parent = static_cast<__end_node_pointer>(__nd);
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
return __parent->__left_;
}
} else {
if (__nd->__right_ != nullptr)
- __nd = static_cast<__node_pointer>(__nd->__right_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
else {
- __parent = static_cast<__end_node_pointer>(__nd);
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
return __nd->__right_;
}
}
@@ -1752,7 +1906,8 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf_high(__end_node_pointer& __parent
// Set __parent to parent of null leaf
// Return reference to null leaf
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_leaf(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&
+__tree<_Tp, _Compare, _Allocator>::__find_leaf(
const_iterator __hint, __end_node_pointer& __parent, const value_type& __v) {
if (__hint == end() || !value_comp()(*__hint, __v)) // check before
{
@@ -1761,11 +1916,11 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
if (__prior == begin() || !value_comp()(__v, *--__prior)) {
// *prev(__hint) <= __v <= *__hint
if (__hint.__ptr_->__left_ == nullptr) {
- __parent = static_cast<__end_node_pointer>(__hint.__ptr_);
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__hint.__ptr_);
return __parent->__left_;
} else {
- __parent = static_cast<__end_node_pointer>(__prior.__ptr_);
- return static_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
+ __parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__prior.__ptr_);
+ return std::__static_fancy_pointer_cast<__node_base_pointer>(__prior.__ptr_)->__right_;
}
}
// __v < *prev(__hint)
@@ -1780,8 +1935,9 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
// If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf.
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-_LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
- typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
+ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
__tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
using _Pair = pair<__end_node_pointer, __node_base_pointer&>;
@@ -1801,18 +1957,18 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
if (__comp_res.__less()) {
if (__nd->__left_ == nullptr)
- return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__left_);
+ return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), __nd->__left_);
__node_ptr = std::addressof(__nd->__left_);
- __nd = static_cast<__node_pointer>(__nd->__left_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__left_);
} else if (__comp_res.__greater()) {
if (__nd->__right_ == nullptr)
- return _Pair(static_cast<__end_node_pointer>(__nd), __nd->__right_);
+ return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), __nd->__right_);
__node_ptr = std::addressof(__nd->__right_);
- __nd = static_cast<__node_pointer>(__nd->__right_);
+ __nd = std::__static_fancy_pointer_cast<__node_pointer>(__nd->__right_);
} else {
- return _Pair(static_cast<__end_node_pointer>(__nd), *__node_ptr);
+ return _Pair(std::__static_fancy_pointer_cast<__end_node_pointer>(__nd), *__node_ptr);
}
}
}
@@ -1825,8 +1981,9 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
// If __v doesn't exist, return the parent of the null leaf and a reference to the pointer to the null leaf.
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-_LIBCPP_HIDE_FROM_ABI pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
- typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
+_LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::__end_node_pointer,
+ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer&>
__tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_base_pointer& __dummy, const _Key& __v) {
using _Pair = pair<__end_node_pointer, __node_base_pointer&>;
@@ -1837,7 +1994,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
// *prev(__hint) < __v < *__hint
if (__hint.__ptr_->__left_ == nullptr)
return _Pair(__hint.__ptr_, __hint.__ptr_->__left_);
- return _Pair(__prior.__ptr_, static_cast<__node_pointer>(__prior.__ptr_)->__right_);
+ return _Pair(__prior.__ptr_, std::__static_fancy_pointer_cast<__node_pointer>(__prior.__ptr_)->__right_);
}
// __v <= *prev(__hint)
return __find_equal(__v);
@@ -1849,7 +2006,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
if (__next == end() || value_comp()(__v, *__next)) {
// *__hint < __v < *std::next(__hint)
if (__hint.__get_np()->__right_ == nullptr)
- return _Pair(__hint.__ptr_, static_cast<__node_pointer>(__hint.__ptr_)->__right_);
+ return _Pair(__hint.__ptr_, std::__static_fancy_pointer_cast<__node_pointer>(__hint.__ptr_)->__right_);
return _Pair(__next.__ptr_, __next.__ptr_->__left_);
}
// *next(__hint) <= __v
@@ -1857,12 +2014,12 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const_iterator __hint, __node_ba
}
// else __v == *__hint
- __dummy = static_cast<__node_base_pointer>(__hint.__ptr_);
+ __dummy = std::__static_fancy_pointer_cast<__node_base_pointer>(__hint.__ptr_);
return _Pair(__hint.__ptr_, __dummy);
}
template <class _Tp, class _Compare, class _Allocator>
-void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {
__new_node->__left_ = nullptr;
__new_node->__right_ = nullptr;
@@ -1870,14 +2027,14 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
// __new_node->__is_black_ is initialized in __tree_balance_after_insert
__child = __new_node;
if (__begin_node_->__left_ != nullptr)
- __begin_node_ = static_cast<__end_node_pointer>(__begin_node_->__left_);
+ __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__begin_node_->__left_);
std::__tree_balance_after_insert(__end_node()->__left_, __child);
++__size_;
}
template <class _Tp, class _Compare, class _Allocator>
template <class... _Args>
-typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
__tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
__node_allocator& __na = __node_alloc();
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
@@ -1888,35 +2045,35 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
template <class _Tp, class _Compare, class _Allocator>
template <class... _Args>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+typename __tree<_Tp, _Compare, _Allocator>::iterator _LIBCPP_CONSTEXPR_SINCE_CXX26
__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {
__node_holder __h = __construct_node(std::forward<_Args>(__args)...);
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf_high(__parent, __h->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
- return iterator(static_cast<__node_pointer>(__h.release()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
+ return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__h.release()));
}
template <class _Tp, class _Compare, class _Allocator>
template <class... _Args>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+typename __tree<_Tp, _Compare, _Allocator>::iterator _LIBCPP_CONSTEXPR_SINCE_CXX26
__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) {
__node_holder __h = __construct_node(std::forward<_Args>(__args)...);
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf(__p, __parent, __h->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get()));
- return iterator(static_cast<__node_pointer>(__h.release()));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__h.get()));
+ return iterator(std::__static_fancy_pointer_cast<__node_pointer>(__h.release()));
}
template <class _Tp, class _Compare, class _Allocator>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
+pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool> _LIBCPP_CONSTEXPR_SINCE_CXX26
__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, __node_pointer __nd) {
auto [__parent, __child] = __find_equal(__v);
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
bool __inserted = false;
if (__child == nullptr) {
__assign_value(__nd->__get_value(), __v);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd));
__r = __nd;
__inserted = true;
}
@@ -1924,39 +2081,39 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, _
}
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf_high(__parent, __nd->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd));
return iterator(__nd);
}
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) {
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf(__p, __parent, __nd->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__nd));
return iterator(__nd);
}
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__remove_node_pointer(__node_pointer __ptr) _NOEXCEPT {
iterator __r(__ptr);
++__r;
if (__begin_node_ == __ptr)
__begin_node_ = __r.__ptr_;
--__size_;
- std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__ptr));
+ std::__tree_remove(__end_node()->__left_, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
return __r;
}
#if _LIBCPP_STD_VER >= 17
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle, class _InsertReturnType>
-_LIBCPP_HIDE_FROM_ABI _InsertReturnType
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _InsertReturnType
__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __nh) {
if (__nh.empty())
return _InsertReturnType{end(), false, _NodeHandle()};
@@ -1964,16 +2121,17 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n
__node_pointer __ptr = __nh.__ptr_;
auto [__parent, __child] = __find_equal(__ptr->__get_value());
if (__child != nullptr)
- return _InsertReturnType{iterator(static_cast<__node_pointer>(__child)), false, std::move(__nh)};
+ return _InsertReturnType{
+ iterator(std::__static_fancy_pointer_cast<__node_pointer>(__child)), false, std::move(__nh)};
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
__nh.__release_ptr();
return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};
}
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle>
-_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __hint, _NodeHandle&& __nh) {
if (__nh.empty())
return end();
@@ -1981,9 +2139,9 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
__node_pointer __ptr = __nh.__ptr_;
__node_base_pointer __dummy;
auto [__parent, __child] = __find_equal(__hint, __dummy, __ptr->__get_value());
- __node_pointer __r = static_cast<__node_pointer>(__child);
+ __node_pointer __r = std::__static_fancy_pointer_cast<__node_pointer>(__child);
if (__child == nullptr) {
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
__r = __ptr;
__nh.__release_ptr();
}
@@ -1992,7 +2150,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle>
-_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const& __key) {
iterator __it = find(__key);
if (__it == end())
return _NodeHandle();
@@ -2001,7 +2160,8 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle>
-_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _NodeHandle
+__tree<_Tp, _Compare, _Allocator>::__node_handle_extract(const_iterator __p) {
__node_pointer __np = __p.__get_np();
__remove_node_pointer(__np);
return _NodeHandle(__np, __alloc());
@@ -2009,7 +2169,7 @@ _LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_hand
template <class _Tp, class _Compare, class _Allocator>
template <class _Comp2>
-_LIBCPP_HIDE_FROM_ABI void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2, _Allocator>& __source) {
for (iterator __i = __source.begin(); __i != __source.end();) {
__node_pointer __src_ptr = __i.__get_np();
@@ -2018,27 +2178,27 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_unique(__tree<_Tp, _Comp2
if (__child != nullptr)
continue;
__source.__remove_node_pointer(__src_ptr);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__src_ptr));
}
}
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle>
-_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh) {
if (__nh.empty())
return end();
__node_pointer __ptr = __nh.__ptr_;
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf_high(__parent, __ptr->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
__nh.__release_ptr();
return iterator(__ptr);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _NodeHandle>
-_LIBCPP_HIDE_FROM_ABI typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __hint, _NodeHandle&& __nh) {
if (__nh.empty())
return end();
@@ -2046,14 +2206,14 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h
__node_pointer __ptr = __nh.__ptr_;
__end_node_pointer __parent;
__node_base_pointer& __child = __find_leaf(__hint, __parent, __ptr->__get_value());
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__ptr));
__nh.__release_ptr();
return iterator(__ptr);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Comp2>
-_LIBCPP_HIDE_FROM_ABI void
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
__tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2, _Allocator>& __source) {
for (iterator __i = __source.begin(); __i != __source.end();) {
__node_pointer __src_ptr = __i.__get_np();
@@ -2061,14 +2221,15 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_merge_multi(__tree<_Tp, _Comp2,
__node_base_pointer& __child = __find_leaf_high(__parent, __src_ptr->__get_value());
++__i;
__source.__remove_node_pointer(__src_ptr);
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__src_ptr));
+ __insert_node_at(__parent, __child, std::__static_fancy_pointer_cast<__node_base_pointer>(__src_ptr));
}
}
#endif // _LIBCPP_STD_VER >= 17
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26
+ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __p) {
__node_pointer __np = __p.__get_np();
iterator __r = __remove_node_pointer(__np);
__node_allocator& __na = __node_alloc();
@@ -2078,7 +2239,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo
}
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
__tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) {
while (__f != __l)
__f = erase(__f);
@@ -2087,7 +2248,7 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l)
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {
iterator __i = find(__k);
if (__i == end())
@@ -2098,7 +2259,7 @@ __tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {
pair<iterator, iterator> __p = __equal_range_multi(__k);
size_type __r = 0;
@@ -2109,16 +2270,16 @@ __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {
__node_pointer __rt = __root();
auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp());
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
return 1;
}
@@ -2127,7 +2288,7 @@ __tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::size_type
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::size_type
__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
__end_node_pointer __result = __end_node();
__node_pointer __rt = __root();
@@ -2135,78 +2296,85 @@ __tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
return std::distance(
- __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
- __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+ __lower_bound_multi(__k,
+ std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
+ std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
+ __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
}
return 0;
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
while (__root != nullptr) {
if (!value_comp()(__root->__get_value(), __v)) {
- __result = static_cast<__end_node_pointer>(__root);
- __root = static_cast<__node_pointer>(__root->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
} else
- __root = static_cast<__node_pointer>(__root->__right_);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
}
return iterator(__result);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::__lower_bound_multi(
const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
while (__root != nullptr) {
if (!value_comp()(__root->__get_value(), __v)) {
- __result = static_cast<__end_node_pointer>(__root);
- __root = static_cast<__node_pointer>(__root->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
} else
- __root = static_cast<__node_pointer>(__root->__right_);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
}
return const_iterator(__result);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::iterator
+__tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
const _Key& __v, __node_pointer __root, __end_node_pointer __result) {
while (__root != nullptr) {
if (value_comp()(__v, __root->__get_value())) {
- __result = static_cast<__end_node_pointer>(__root);
- __root = static_cast<__node_pointer>(__root->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
} else
- __root = static_cast<__node_pointer>(__root->__right_);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
}
return iterator(__result);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-typename __tree<_Tp, _Compare, _Allocator>::const_iterator __tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::const_iterator
+__tree<_Tp, _Compare, _Allocator>::__upper_bound_multi(
const _Key& __v, __node_pointer __root, __end_node_pointer __result) const {
while (__root != nullptr) {
if (value_comp()(__v, __root->__get_value())) {
- __result = static_cast<__end_node_pointer>(__root);
- __root = static_cast<__node_pointer>(__root->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__root);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__left_);
} else
- __root = static_cast<__node_pointer>(__root->__right_);
+ __root = std::__static_fancy_pointer_cast<__node_pointer>(__root->__right_);
}
return const_iterator(__result);
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
-__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26
+ pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
+ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
using _Pp = pair<iterator, iterator>;
__end_node_pointer __result = __end_node();
__node_pointer __rt = __root();
@@ -2214,22 +2382,23 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
return _Pp(iterator(__rt),
- iterator(__rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
- : __result));
+ iterator(__rt->__right_ != nullptr
+ ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
+ : __result));
}
return _Pp(iterator(__result), iterator(__result));
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
- typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
__tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
using _Pp = pair<const_iterator, const_iterator>;
__end_node_pointer __result = __end_node();
@@ -2238,23 +2407,25 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
return _Pp(
const_iterator(__rt),
- const_iterator(
- __rt->__right_ != nullptr ? static_cast<__end_node_pointer>(std::__tree_min(__rt->__right_)) : __result));
+ const_iterator(__rt->__right_ != nullptr
+ ? std::__static_fancy_pointer_cast<__end_node_pointer>(std::__tree_min(__rt->__right_))
+ : __result));
}
return _Pp(const_iterator(__result), const_iterator(__result));
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
-__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26
+ pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp, _Compare, _Allocator>::iterator>
+ __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
using _Pp = pair<iterator, iterator>;
__end_node_pointer __result = __end_node();
__node_pointer __rt = __root();
@@ -2262,22 +2433,23 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
- return _Pp(
- __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
- __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+ return _Pp(__lower_bound_multi(__k,
+ std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
+ std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
+ __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
}
return _Pp(iterator(__result), iterator(__result));
}
template <class _Tp, class _Compare, class _Allocator>
template <class _Key>
-pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
- typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
+_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
+ typename __tree<_Tp, _Compare, _Allocator>::const_iterator>
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
using _Pp = pair<const_iterator, const_iterator>;
__end_node_pointer __result = __end_node();
@@ -2286,35 +2458,37 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
while (__rt != nullptr) {
auto __comp_res = __comp(__k, __rt->__get_value());
if (__comp_res.__less()) {
- __result = static_cast<__end_node_pointer>(__rt);
- __rt = static_cast<__node_pointer>(__rt->__left_);
+ __result = std::__static_fancy_pointer_cast<__end_node_pointer>(__rt);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_);
} else if (__comp_res.__greater())
- __rt = static_cast<__node_pointer>(__rt->__right_);
+ __rt = std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_);
else
- return _Pp(
- __lower_bound_multi(__k, static_cast<__node_pointer>(__rt->__left_), static_cast<__end_node_pointer>(__rt)),
- __upper_bound_multi(__k, static_cast<__node_pointer>(__rt->__right_), __result));
+ return _Pp(__lower_bound_multi(__k,
+ std::__static_fancy_pointer_cast<__node_pointer>(__rt->__left_),
+ std::__static_fancy_pointer_cast<__end_node_pointer>(__rt)),
+ __upper_bound_multi(__k, std::__static_fancy_pointer_cast<__node_pointer>(__rt->__right_), __result));
}
return _Pp(const_iterator(__result), const_iterator(__result));
}
template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::__node_holder
+_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_holder
__tree<_Tp, _Compare, _Allocator>::remove(const_iterator __p) _NOEXCEPT {
__node_pointer __np = __p.__get_np();
if (__begin_node_ == __p.__ptr_) {
if (__np->__right_ != nullptr)
- __begin_node_ = static_cast<__end_node_pointer>(__np->__right_);
+ __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__np->__right_);
else
- __begin_node_ = static_cast<__end_node_pointer>(__np->__parent_);
+ __begin_node_ = std::__static_fancy_pointer_cast<__end_node_pointer>(__np->__parent_);
}
--__size_;
- std::__tree_remove(__end_node()->__left_, static_cast<__node_base_pointer>(__np));
+ std::__tree_remove(__end_node()->__left_, std::__static_fancy_pointer_cast<__node_base_pointer>(__np));
return __node_holder(__np, _Dp(__node_alloc(), true));
}
template <class _Tp, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI void swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y)
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+swap(__tree<_Tp, _Compare, _Allocator>& __x, __tree<_Tp, _Compare, _Allocator>& __y)
_NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
__x.swap(__y);
}
diff --git a/libcxx/include/__type_traits/make_transparent.h b/libcxx/include/__type_traits/make_transparent.h
index 4d3207a807fa7..efcce0011f60d 100644
--- a/libcxx/include/__type_traits/make_transparent.h
+++ b/libcxx/include/__type_traits/make_transparent.h
@@ -33,12 +33,12 @@ template <class _Comparator>
using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_Comparator>::type;
template <class _Comparator, __enable_if_t<is_same<_Comparator, __make_transparent_t<_Comparator> >::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _Comparator& __as_transparent(_Comparator& __comp) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Comparator& __as_transparent(_Comparator& __comp) {
return __comp;
}
template <class _Comparator, __enable_if_t<!is_same<_Comparator, __make_transparent_t<_Comparator> >::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_Comparator> __as_transparent(_Comparator&) {
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __make_transparent_t<_Comparator> __as_transparent(_Comparator&) {
static_assert(is_empty<_Comparator>::value);
return __make_transparent_t<_Comparator>();
}
diff --git a/libcxx/include/__utility/default_three_way_comparator.h b/libcxx/include/__utility/default_three_way_comparator.h
index 92cdce6aae117..3f6bb1d7455b6 100644
--- a/libcxx/include/__utility/default_three_way_comparator.h
+++ b/libcxx/include/__utility/default_three_way_comparator.h
@@ -31,7 +31,7 @@ template <class _LHS, class _RHS>
struct __default_three_way_comparator<_LHS,
_RHS,
__enable_if_t<is_arithmetic<_LHS>::value && is_arithmetic<_RHS>::value> > {
- _LIBCPP_HIDE_FROM_ABI static int operator()(_LHS __lhs, _RHS __rhs) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static int operator()(_LHS __lhs, _RHS __rhs) {
if (__lhs < __rhs)
return -1;
if (__lhs > __rhs)
diff --git a/libcxx/include/__utility/lazy_synth_three_way_comparator.h b/libcxx/include/__utility/lazy_synth_three_way_comparator.h
index 8c78742ccb4e3..3b2c7aa4de83f 100644
--- a/libcxx/include/__utility/lazy_synth_three_way_comparator.h
+++ b/libcxx/include/__utility/lazy_synth_three_way_comparator.h
@@ -34,14 +34,14 @@ struct __lazy_compare_result {
const _LHS& __lhs_;
const _RHS& __rhs_;
- _LIBCPP_HIDE_FROM_ABI
- __lazy_compare_result(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp,
- _LIBCPP_CTOR_LIFETIMEBOUND const _LHS& __lhs,
- _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_compare_result(
+ _LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp,
+ _LIBCPP_CTOR_LIFETIMEBOUND const _LHS& __lhs,
+ _LIBCPP_CTOR_LIFETIMEBOUND const _RHS& __rhs)
: __comp_(__comp), __lhs_(__lhs), __rhs_(__rhs) {}
- _LIBCPP_HIDE_FROM_ABI bool __less() const { return __comp_(__lhs_, __rhs_); }
- _LIBCPP_HIDE_FROM_ABI bool __greater() const { return __comp_(__rhs_, __lhs_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __less() const { return __comp_(__lhs_, __rhs_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __greater() const { return __comp_(__rhs_, __lhs_); }
};
// This class provides three way comparison between _LHS and _RHS as efficiently as possible. This can be specialized if
@@ -51,10 +51,11 @@ template <class _Comparator, class _LHS, class _RHS, class = void>
struct __lazy_synth_three_way_comparator {
const _Comparator& __comp_;
- _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator& __comp)
: __comp_(__comp) {}
- _LIBCPP_HIDE_FROM_ABI __lazy_compare_result<_Comparator, _LHS, _RHS>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __lazy_compare_result<_Comparator, _LHS, _RHS>
operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) const {
return __lazy_compare_result<_Comparator, _LHS, _RHS>(__comp_, __lhs, __rhs);
}
@@ -63,10 +64,10 @@ struct __lazy_synth_three_way_comparator {
struct __eager_compare_result {
int __res_;
- _LIBCPP_HIDE_FROM_ABI explicit __eager_compare_result(int __res) : __res_(__res) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __eager_compare_result(int __res) : __res_(__res) {}
- _LIBCPP_HIDE_FROM_ABI bool __less() const { return __res_ < 0; }
- _LIBCPP_HIDE_FROM_ABI bool __greater() const { return __res_ > 0; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __less() const { return __res_ < 0; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool __greater() const { return __res_ > 0; }
};
template <class _Comparator, class _LHS, class _RHS>
@@ -77,10 +78,11 @@ struct __lazy_synth_three_way_comparator<_Comparator,
__has_default_three_way_comparator<_LHS, _RHS> >::value> > {
// This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of
// the comparator.
- _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
// Same comment as above.
- _LIBCPP_HIDE_FROM_ABI static __eager_compare_result
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __eager_compare_result
operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) {
return __eager_compare_result(__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs));
}
@@ -94,10 +96,11 @@ struct __lazy_synth_three_way_comparator<_Comparator,
__has_default_three_way_comparator<_LHS, _RHS> >::value> > {
// This lifetimebound annotation is technically incorrect, but other specializations actually capture the lifetime of
// the comparator.
- _LIBCPP_HIDE_FROM_ABI __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ __lazy_synth_three_way_comparator(_LIBCPP_CTOR_LIFETIMEBOUND const _Comparator&) {}
// Same comment as above.
- _LIBCPP_HIDE_FROM_ABI static __eager_compare_result
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __eager_compare_result
operator()(_LIBCPP_LIFETIMEBOUND const _LHS& __lhs, _LIBCPP_LIFETIMEBOUND const _RHS& __rhs) {
return __eager_compare_result(-__default_three_way_comparator<_LHS, _RHS>()(__lhs, __rhs));
}
diff --git a/libcxx/include/__utility/try_key_extraction.h b/libcxx/include/__utility/try_key_extraction.h
index 755c08214019f..3423d746dee7f 100644
--- a/libcxx/include/__utility/try_key_extraction.h
+++ b/libcxx/include/__utility/try_key_extraction.h
@@ -28,7 +28,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _KeyT, class _Ret, class _WithKey, class _WithoutKey, class... _Args>
-_LIBCPP_HIDE_FROM_ABI _Ret
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
__try_key_extraction_impl(__priority_tag<0>, _WithKey, _WithoutKey __without_key, _Args&&... __args) {
return __without_key(std::forward<_Args>(__args)...);
}
@@ -39,7 +39,7 @@ template <class _KeyT,
class _WithoutKey,
class _Arg,
__enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg> >::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _Ret
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) {
return __with_key(__arg, std::forward<_Arg>(__arg));
}
@@ -52,7 +52,7 @@ template <class _KeyT,
__enable_if_t<__is_pair_v<__remove_const_ref_t<_Arg> > &&
is_same<__remove_const_t<typename __remove_const_ref_t<_Arg>::first_type>, _KeyT>::value,
int> = 0>
-_LIBCPP_HIDE_FROM_ABI _Ret
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg&& __arg) {
return __with_key(__arg.first, std::forward<_Arg>(__arg));
}
@@ -64,7 +64,7 @@ template <class _KeyT,
class _Arg1,
class _Arg2,
__enable_if_t<is_same<_KeyT, __remove_const_ref_t<_Arg1> >::value, int> = 0>
-_LIBCPP_HIDE_FROM_ABI _Ret
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret
__try_key_extraction_impl(__priority_tag<1>, _WithKey __with_key, _WithoutKey, _Arg1&& __arg1, _Arg2&& __arg2) {
return __with_key(__arg1, std::forward<_Arg1>(__arg1), std::forward<_Arg2>(__arg2));
}
@@ -81,7 +81,7 @@ template <class _KeyT,
__is_tuple_v<_Tuple1> && tuple_size<_Tuple1>::value == 1 &&
is_same<__remove_const_ref_t<typename tuple_element<0, _Tuple1>::type>, _KeyT>::value,
int> = 0>
-_LIBCPP_HIDE_FROM_ABI _Ret __try_key_extraction_impl(
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 _Ret __try_key_extraction_impl(
__priority_tag<1>,
_WithKey __with_key,
_WithoutKey,
@@ -102,7 +102,7 @@ _LIBCPP_HIDE_FROM_ABI _Ret __try_key_extraction_impl(
//
// Both `__with_key` and `__without_key` must take all arguments by reference.
template <class _KeyT, class _WithKey, class _WithoutKey, class... _Args>
-_LIBCPP_HIDE_FROM_ABI decltype(std::declval<_WithoutKey>()(std::declval<_Args>()...))
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 decltype(std::declval<_WithoutKey>()(std::declval<_Args>()...))
__try_key_extraction(_WithKey __with_key, _WithoutKey __without_key, _Args&&... __args) {
using _Ret = decltype(__without_key(std::forward<_Args>(__args)...));
return std::__try_key_extraction_impl<_KeyT, _Ret>(
diff --git a/libcxx/test/support/is_transparent.h b/libcxx/test/support/is_transparent.h
index 9d3791d68a865..846f8fa4d06dd 100644
--- a/libcxx/test/support/is_transparent.h
+++ b/libcxx/test/support/is_transparent.h
@@ -81,16 +81,17 @@ struct transparent_less_not_a_type
};
struct C2Int { // comparable to int
- C2Int() : i_(0) {}
- C2Int(int i): i_(i) {}
- int get () const { return i_; }
+ TEST_CONSTEXPR_CXX26 C2Int() : i_(0) {}
+ TEST_CONSTEXPR_CXX26 C2Int(int i) : i_(i) {}
+ TEST_CONSTEXPR_CXX26 int get() const { return i_; }
+
private:
int i_;
};
-bool operator <(int rhs, const C2Int& lhs) { return rhs < lhs.get(); }
-bool operator <(const C2Int& rhs, const C2Int& lhs) { return rhs.get() < lhs.get(); }
-bool operator <(const C2Int& rhs, int lhs) { return rhs.get() < lhs; }
+ TEST_CONSTEXPR_CXX26 bool operator<(int rhs, const C2Int& lhs) { return rhs < lhs.get(); }
+ TEST_CONSTEXPR_CXX26 bool operator<(const C2Int& rhs, const C2Int& lhs) { return rhs.get() < lhs.get(); }
+ TEST_CONSTEXPR_CXX26 bool operator<(const C2Int& rhs, int lhs) { return rhs.get() < lhs; }
#endif // TEST_STD_VER > 11
diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h
index cd71cd70d6a84..93b579d2dfde3 100644
--- a/libcxx/test/support/poisoned_hash_helper.h
+++ b/libcxx/test/support/poisoned_hash_helper.h
@@ -123,9 +123,13 @@ struct Class {};
// Each header that declares the std::hash template provides enabled
// specializations of std::hash for std::nullptr_t and all cv-unqualified
// arithmetic, enumeration, and pointer types.
-using LibraryHashTypes =
- types::concatenate_t<types::arithmetic_types,
- types::type_list<Enum, EnumClass, void*, void const*, Class*, std::nullptr_t>>;
+#if TEST_STD_VER >= 17
+using MaybeNullptr = types::type_list<std::nullptr_t>;
+#else
+using MaybeNullptr = types::type_list<>;
+#endif
+using LibraryHashTypes = types::
+ concatenate_t<types::arithmetic_types, types::type_list<Enum, EnumClass, void*, void const*, Class*>, MaybeNullptr>;
struct TestHashEnabled {
template <class T>
diff --git a/libcxx/test/support/private_constructor.h b/libcxx/test/support/private_constructor.h
index 24f540c6a7fdc..c7ed288c4032e 100644
--- a/libcxx/test/support/private_constructor.h
+++ b/libcxx/test/support/private_constructor.h
@@ -9,18 +9,22 @@
#ifndef TEST_SUPPORT_PRIVATE_CONSTRUCTOR_H
#define TEST_SUPPORT_PRIVATE_CONSTRUCTOR_H
+#include "test_macros.h"
+
struct PrivateConstructor {
+ TEST_CONSTEXPR_CXX26 PrivateConstructor static make(int v) { return PrivateConstructor(v); }
+ TEST_CONSTEXPR_CXX26 int get() const { return val; }
- PrivateConstructor static make ( int v ) { return PrivateConstructor(v); }
- int get () const { return val; }
private:
- PrivateConstructor ( int v ) : val(v) {}
- int val;
+ TEST_CONSTEXPR_CXX26 PrivateConstructor(int v) : val(v) {}
+ int val;
};
-bool operator < ( const PrivateConstructor &lhs, const PrivateConstructor &rhs ) { return lhs.get() < rhs.get(); }
+ TEST_CONSTEXPR_CXX26 bool operator<(const PrivateConstructor& lhs, const PrivateConstructor& rhs) {
+ return lhs.get() < rhs.get();
+ }
-bool operator < ( const PrivateConstructor &lhs, int rhs ) { return lhs.get() < rhs; }
-bool operator < ( int lhs, const PrivateConstructor &rhs ) { return lhs < rhs.get(); }
+ TEST_CONSTEXPR_CXX26 bool operator<(const PrivateConstructor& lhs, int rhs) { return lhs.get() < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator<(int lhs, const PrivateConstructor& rhs) { return lhs < rhs.get(); }
#endif // TEST_SUPPORT_PRIVATE_CONSTRUCTOR_H
>From 49d74e1a7cec61788ad5ca73ebbf040685e38cd9 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 15:22:15 -0500
Subject: [PATCH 2/9] Add test boilerplate for constexpr testing
---
.../associative/iterator_types.pass.cpp | 9 ++++-
.../containers/associative/set/clear.pass.cpp | 11 +++++--
.../associative/set/contains.pass.cpp | 11 +++++--
.../set/contains_transparent.pass.cpp | 11 +++++--
.../containers/associative/set/count.pass.cpp | 11 +++++--
.../set/count_transparent.pass.cpp | 11 +++++--
.../associative/set/emplace.pass.cpp | 11 +++++--
.../associative/set/emplace_hint.pass.cpp | 11 +++++--
.../containers/associative/set/empty.pass.cpp | 11 +++++--
.../associative/set/equal_range.pass.cpp | 13 ++++++--
.../set/equal_range_transparent.pass.cpp | 17 +++++++---
.../associative/set/erase_iter.pass.cpp | 11 +++++--
.../associative/set/erase_iter_iter.pass.cpp | 11 +++++--
.../associative/set/erase_key.pass.cpp | 11 +++++--
.../associative/set/extract_iterator.pass.cpp | 11 +++++--
.../associative/set/extract_key.pass.cpp | 11 +++++--
.../containers/associative/set/find.pass.cpp | 13 ++++++--
.../associative/set/get_allocator.pass.cpp | 11 +++++--
.../associative/set/incomplete_type.pass.cpp | 11 +++++--
...nd_emplace_allocator_requirements.pass.cpp | 15 ++++++---
.../associative/set/insert_cv.pass.cpp | 11 +++++--
.../set/insert_initializer_list.pass.cpp | 11 +++++--
.../associative/set/insert_iter_cv.pass.cpp | 11 +++++--
.../associative/set/insert_iter_iter.pass.cpp | 11 +++++--
.../associative/set/insert_iter_rv.pass.cpp | 11 +++++--
.../associative/set/insert_node_type.pass.cpp | 11 +++++--
.../set/insert_node_type_hint.pass.cpp | 11 +++++--
.../associative/set/insert_range.pass.cpp | 11 +++++--
.../associative/set/insert_rv.pass.cpp | 11 +++++--
.../associative/set/iterator.pass.cpp | 33 +++++++++++--------
.../associative/set/lower_bound.pass.cpp | 13 ++++++--
.../associative/set/max_size.pass.cpp | 11 +++++--
.../containers/associative/set/merge.pass.cpp | 17 +++++++---
.../associative/set/set.cons/alloc.pass.cpp | 11 +++++--
.../set.cons/assign_initializer_list.pass.cpp | 11 +++++--
.../associative/set/set.cons/compare.pass.cpp | 11 +++++--
.../set/set.cons/compare_alloc.pass.cpp | 11 +++++--
.../associative/set/set.cons/copy.pass.cpp | 11 +++++--
.../set/set.cons/copy_alloc.pass.cpp | 11 +++++--
.../set/set.cons/copy_assign.pass.cpp | 11 +++++--
.../associative/set/set.cons/deduct.pass.cpp | 11 ++++++-
.../associative/set/set.cons/default.pass.cpp | 11 +++++--
.../set/set.cons/default_noexcept.pass.cpp | 11 +++++--
.../set/set.cons/dtor_noexcept.pass.cpp | 11 +++++--
.../set/set.cons/from_range.pass.cpp | 10 +++++-
.../set/set.cons/initializer_list.pass.cpp | 11 +++++--
.../initializer_list_compare.pass.cpp | 11 +++++--
.../initializer_list_compare_alloc.pass.cpp | 13 ++++++--
.../set/set.cons/iter_iter.pass.cpp | 11 +++++--
.../set/set.cons/iter_iter_alloc.pass.cpp | 17 +++++++---
.../set/set.cons/iter_iter_comp.pass.cpp | 11 +++++--
.../associative/set/set.cons/move.pass.cpp | 11 +++++--
.../set/set.cons/move_alloc.pass.cpp | 11 +++++--
.../set/set.cons/move_assign.pass.cpp | 11 +++++--
.../set/set.cons/move_noexcept.pass.cpp | 13 ++++++--
.../set/set.erasure/erase_if.pass.cpp | 11 +++++--
.../set.nonmember/compare.three_way.pass.cpp | 13 ++++++--
.../set/set.nonmember/op_compare.pass.cpp | 33 +++++++++++--------
.../set/set.observers/comp.pass.cpp | 13 ++++++--
.../set/set.special/member_swap.pass.cpp | 11 +++++--
.../set/set.special/non_member_swap.pass.cpp | 11 +++++--
.../set/set.special/swap_noexcept.pass.cpp | 11 +++++--
.../containers/associative/set/size.pass.cpp | 11 +++++--
.../containers/associative/set/types.pass.cpp | 9 ++++-
.../associative/set/upper_bound.pass.cpp | 13 ++++++--
65 files changed, 625 insertions(+), 167 deletions(-)
diff --git a/libcxx/test/std/containers/associative/iterator_types.pass.cpp b/libcxx/test/std/containers/associative/iterator_types.pass.cpp
index 2800549905f1b..f394b000615d8 100644
--- a/libcxx/test/std/containers/associative/iterator_types.pass.cpp
+++ b/libcxx/test/std/containers/associative/iterator_types.pass.cpp
@@ -46,7 +46,7 @@ void testSet() {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::map<int, int> Map;
typedef std::pair<const int, int> ValueTp;
@@ -124,5 +124,12 @@ 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/associative/set/clear.pass.cpp b/libcxx/test/std/containers/associative/set/clear.pass.cpp
index a53b6a86a660e..fbcde898950c0 100644
--- a/libcxx/test/std/containers/associative/set/clear.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/clear.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// void clear() noexcept;
+// constexpr void clear() noexcept; // constexpr since C++26
#include <set>
#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::set<int> M;
typedef int V;
@@ -42,5 +42,12 @@ 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/associative/set/contains.pass.cpp b/libcxx/test/std/containers/associative/set/contains.pass.cpp
index 93e6ff0a28885..20b1eeb839414 100644
--- a/libcxx/test/std/containers/associative/set/contains.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/contains.pass.cpp
@@ -13,7 +13,7 @@
// <set>
-// bool contains(const key_type& x) const;
+// constexpr bool contains(const key_type& x) const; // constexpr since C++26
template <typename T, typename V, typename B, typename... Vals>
void test(B bad, Vals... args) {
@@ -34,7 +34,7 @@ struct E {
char c = 1;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
test<std::set<int>, int>(14, 10, 11, 12, 13);
test<std::set<char>, char>('e', 'a', 'b', 'c', 'd');
@@ -44,5 +44,12 @@ int main(int, char**) {
test<std::multiset<char>, char>('e', 'a', 'b', 'c', 'd');
}
+ 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/associative/set/contains_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
index c5d6b293e8a4b..acd03e649095f 100644
--- a/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// template<typename K> bool contains(const K& x) const; // C++20
+// template<typename K> constexpr bool contains(const K& x) const; // C++20 // constexpr since C++26
#include <cassert>
#include <set>
@@ -36,9 +36,16 @@ void test() {
assert(!s.contains(-1));
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test<std::set<std::pair<int, int>, Comp> >();
test<std::multiset<std::pair<int, int>, Comp> >();
+ 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/associative/set/count.pass.cpp b/libcxx/test/std/containers/associative/set/count.pass.cpp
index abd1e98f1a4ee..486220f1004c7 100644
--- a/libcxx/test/std/containers/associative/set/count.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/count.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// size_type count(const key_type& k) const;
+// constexpr size_type count(const key_type& k) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -19,7 +19,7 @@
#include "min_allocator.h"
#include "private_constructor.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -136,5 +136,12 @@ 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/associative/set/count_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
index 4e0b610292460..9147b38e5d336 100644
--- a/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
@@ -13,7 +13,7 @@
// class set
// template<typename K>
-// size_type count(const K& x) const; // C++14
+// constexpr size_type count(const K& x) const; // C++14 // constexpr since C++26
#include <cassert>
#include <set>
@@ -29,11 +29,18 @@ struct Comp {
bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
std::set<std::pair<int, int>, Comp> s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
auto cnt = s.count(1);
assert(cnt == 3);
+ 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/associative/set/emplace.pass.cpp b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
index e5a9f9590aad0..fecd9ef2fe7f9 100644
--- a/libcxx/test/std/containers/associative/set/emplace.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
@@ -13,7 +13,7 @@
// class set
// template <class... Args>
-// pair<iterator, bool> emplace(Args&&... args);
+// constexpr pair<iterator, bool> emplace(Args&&... args); // constexpr since C++26
#include <cassert>
#include <set>
@@ -23,7 +23,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<DefaultOnly> M;
typedef std::pair<M::iterator, bool> R;
@@ -92,5 +92,12 @@ int main(int, char**) {
assert(set.begin() == std::get<0>(res));
}
+ 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/associative/set/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
index 9f0d5fbd2c5e5..5c68000ffbab9 100644
--- a/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
@@ -13,7 +13,7 @@
// class set
// template <class... Args>
-// iterator emplace_hint(const_iterator position, Args&&... args);
+// constexpr iterator emplace_hint(const_iterator position, Args&&... args); // constexpr since C++26
#include <set>
#include <cassert>
@@ -23,7 +23,7 @@
#include "DefaultOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<DefaultOnly> M;
typedef M::iterator R;
@@ -78,5 +78,12 @@ int main(int, char**) {
assert(*r == 2);
}
+ 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/associative/set/empty.pass.cpp b/libcxx/test/std/containers/associative/set/empty.pass.cpp
index aaefade5cff7b..e6bcf2a58d103 100644
--- a/libcxx/test/std/containers/associative/set/empty.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/empty.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// bool empty() const;
+// constexpr bool empty() const; // constexpr since C++26
#include <set>
#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::set<int> M;
M m;
@@ -40,5 +40,12 @@ 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/associative/set/equal_range.pass.cpp b/libcxx/test/std/containers/associative/set/equal_range.pass.cpp
index 239aa3e878426..d59cfe2daee87 100644
--- a/libcxx/test/std/containers/associative/set/equal_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/equal_range.pass.cpp
@@ -10,8 +10,8 @@
// class set
-// pair<iterator,iterator> equal_range(const key_type& k);
-// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+// constexpr pair<iterator,iterator> equal_range(const key_type& k); // constexpr since C++26
+// constexpr pair<const_iterator,const_iterator> equal_range(const key_type& k) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "private_constructor.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -327,5 +327,12 @@ 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/associative/set/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
index a44fcf4b74a02..92c1c64be658c 100644
--- a/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
@@ -13,11 +13,11 @@
// class set
// template<typename K>
-// pair<iterator,iterator> equal_range(const K& x); //
-// C++14
+// constexpr pair<iterator,iterator> equal_range(const K& x); //
+// C++14, constexpr since C++26
// template<typename K>
-// pair<const_iterator,const_iterator> equal_range(const K& x) const; //
-// C++14
+// constexpr pair<const_iterator,const_iterator> equal_range(const K& x) const; //
+// C++14, constexpr since C++26
#include <cassert>
#include <set>
@@ -33,7 +33,7 @@ struct Comp {
bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
std::set<std::pair<int, int>, Comp> s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
auto er = s.equal_range(1);
@@ -46,5 +46,12 @@ int main(int, char**) {
assert(nels == 3);
+ 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/associative/set/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
index 73a4cc4266ec9..7682a81dc7407 100644
--- a/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// iterator erase(const_iterator position);
+// constexpr iterator erase(const_iterator position); // constexpr since C++26
#include <set>
#include <cassert>
@@ -25,7 +25,7 @@ struct TemplateConstructor {
bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<int> M;
typedef int V;
@@ -179,5 +179,12 @@ 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/associative/set/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp
index 20c97c28fce56..9c3ba0abc990c 100644
--- a/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// iterator erase(const_iterator first, const_iterator last);
+// constexpr iterator erase(const_iterator first, const_iterator last); // constexpr since C++26
#include <set>
#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::set<int> M;
typedef int V;
@@ -118,5 +118,12 @@ 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/associative/set/erase_key.pass.cpp b/libcxx/test/std/containers/associative/set/erase_key.pass.cpp
index 318c35d21cd87..abf82be8a1bcf 100644
--- a/libcxx/test/std/containers/associative/set/erase_key.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/erase_key.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// size_type erase(const key_type& k);
+// constexpr size_type erase(const key_type& k); // constexpr since C++26
#include <set>
#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::set<int> M;
typedef int V;
@@ -180,5 +180,12 @@ 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/associative/set/extract_iterator.pass.cpp b/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
index 2d7b6e521d961..1511b08079d03 100644
--- a/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// node_type extract(const_iterator);
+// constexpr node_type extract(const_iterator); // constexpr since C++26
#include <set>
#include "test_macros.h"
@@ -35,7 +35,7 @@ void test(Container& c) {
assert(c.size() == 0);
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
using set_type = std::set<int>;
set_type m = {1, 2, 3, 4, 5, 6};
@@ -55,5 +55,12 @@ int main(int, char**) {
test(m);
}
+ 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/associative/set/extract_key.pass.cpp b/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
index 0802387f2c9b3..07f6d193179a8 100644
--- a/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// node_type extract(key_type const&);
+// constexpr node_type extract(key_type const&); // constexpr since C++26
#include <set>
#include "test_macros.h"
@@ -41,7 +41,7 @@ void test(Container& c, KeyTypeIter first, KeyTypeIter last) {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::set<int> m = {1, 2, 3, 4, 5, 6};
int keys[] = {1, 2, 3, 4, 5, 6};
@@ -65,5 +65,12 @@ int main(int, char**) {
test(m, std::begin(keys), std::end(keys));
}
+ 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/associative/set/find.pass.cpp b/libcxx/test/std/containers/associative/set/find.pass.cpp
index deb193c17bfa9..e88441ed8927d 100644
--- a/libcxx/test/std/containers/associative/set/find.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/find.pass.cpp
@@ -10,8 +10,8 @@
// class set
-// iterator find(const key_type& k);
-// const_iterator find(const key_type& k) const;
+// constexpr iterator find(const key_type& k); // constexpr since C++26
+// constexpr const_iterator find(const key_type& k) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "private_constructor.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -202,5 +202,12 @@ 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/associative/set/get_allocator.pass.cpp b/libcxx/test/std/containers/associative/set/get_allocator.pass.cpp
index 0270c9e82ab0e..a2bca7af5bd41 100644
--- a/libcxx/test/std/containers/associative/set/get_allocator.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/get_allocator.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// allocator_type get_allocator() const
+// constexpr allocator_type get_allocator() const // constexpr since C++26
#include <set>
#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::set<int> s(alloc);
@@ -29,5 +29,12 @@ int main(int, char**) {
const std::set<int, std::less<int>, other_allocator<int> > s(alloc);
assert(s.get_allocator() == alloc);
}
+ 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/associative/set/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp
index acbda713619bd..e9db3b31f14a4 100644
--- a/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/incomplete_type.pass.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// <set>
+// <set> // constexpr since C++26
// Check that std::set and its iterators can be instantiated with an incomplete
// type.
@@ -25,8 +25,15 @@ struct A {
inline bool operator==(A const& L, A const& R) { return &L == &R; }
inline bool operator<(A const& L, A const& R) { return L.data < R.data; }
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
A a;
+ 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/associative/set/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
index 4711473de4dad..ace31eb66ea8d 100644
--- a/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
@@ -10,9 +10,9 @@
// class set
-// insert(...)
-// emplace(...)
-// emplace_hint(...)
+// constexpr insert(...) // constexpr since C++26
+// constexpr emplace(...) // constexpr since C++26
+// constexpr emplace_hint(...) // constexpr since C++26
// UNSUPPORTED: c++03
@@ -21,10 +21,17 @@
#include "container_test_types.h"
#include "../../set_allocator_requirement_test_templates.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
testSetInsert<TCT::set<> >();
testSetEmplace<TCT::set<> >();
testSetEmplaceHint<TCT::set<> >();
+ 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/associative/set/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
index 2683f2924e760..ef278224f0229 100644
--- a/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// pair<iterator, bool> insert(const value_type& v);
+// constexpr pair<iterator, bool> insert(const value_type& v); // constexpr since C++26
#include <set>
#include <cassert>
@@ -53,7 +53,7 @@ void do_insert_cv_test() {
assert(*r.first == 3);
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
do_insert_cv_test<std::set<int> >();
#if TEST_STD_VER >= 11
{
@@ -62,5 +62,12 @@ 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/associative/set/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp
index f3b69a59987e8..9ebf723e2af44 100644
--- a/libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// void insert(initializer_list<value_type> il);
+// constexpr void insert(initializer_list<value_type> il); // constexpr since C++26
#include <set>
#include <cassert>
@@ -21,7 +21,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<int> C;
typedef C::value_type V;
@@ -57,5 +57,12 @@ int main(int, char**) {
assert(*++i == V(10));
}
+ 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/associative/set/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp
index 159487ee0e479..506e06d23bc43 100644
--- a/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// iterator insert(const_iterator position, const value_type& v);
+// constexpr iterator insert(const_iterator position, const value_type& v); // constexpr since C++26
#include <set>
#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::set<int> M;
typedef M::iterator R;
@@ -70,5 +70,12 @@ 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/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
index 8576c63a72de9..6d6bd185afa04 100644
--- a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
@@ -11,7 +11,7 @@
// class set
// template <class InputIterator>
-// void insert(InputIterator first, InputIterator last);
+// constexpr void insert(InputIterator first, InputIterator last); // constexpr since C++26
#include <array>
#include <cassert>
@@ -183,8 +183,15 @@ void test() {
test_alloc<cpp17_input_iterator<int*>, min_allocator<int> >();
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test();
+ 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/associative/set/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp
index 21358f3c40c9c..73031dfae5fd7 100644
--- a/libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// iterator insert(const_iterator position, value_type&& v);
+// constexpr iterator insert(const_iterator position, value_type&& v); // constexpr since C++26
#include <set>
#include <cassert>
@@ -22,7 +22,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<MoveOnly> M;
typedef M::iterator R;
@@ -72,5 +72,12 @@ int main(int, char**) {
assert(*r == 3);
}
+ 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/associative/set/insert_node_type.pass.cpp b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
index 9794b4da989d9..935a90afedb2b 100644
--- a/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// insert_return_type insert(node_type&&);
+// constexpr insert_return_type insert(node_type&&); // constexpr since C++26
#include <memory>
#include <set>
@@ -94,11 +94,18 @@ void test(Container& c) {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
std::set<int> m;
test(m);
std::set<int, std::less<int>, min_allocator<int>> m2;
test(m2);
+ 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/associative/set/insert_node_type_hint.pass.cpp b/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
index 1449be0030fe5..f14263595ac6a 100644
--- a/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// iterator insert(const_iterator hint, node_type&&);
+// constexpr iterator insert(const_iterator hint, node_type&&); // constexpr since C++26
#include <set>
#include "test_macros.h"
@@ -47,11 +47,18 @@ void test(Container& c) {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
std::set<int> m;
test(m);
std::set<int, std::less<int>, min_allocator<int>> m2;
test(m2);
+ 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/associative/set/insert_range.pass.cpp b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
index e6c54d84d6e40..654d4d425774a 100644
--- a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
@@ -13,14 +13,14 @@
// <set>
// template<container-compatible-range<value_type> R>
-// void insert_range(R&& rg); // C++23
+// constexpr void insert_range(R&& rg); // C++23, constexpr since C++26
#include <set>
#include "../../insert_range_maps_sets.h"
#include "test_macros.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
for_all_iterators_and_allocators<int, const int*>([]<class Iter, class Sent, class Alloc>() {
test_map_set_insert_range<std::set<int, test_less<int>, Alloc>, int, Iter, Sent>();
});
@@ -32,5 +32,12 @@ int main(int, char**) {
test_set_insert_range_exception_safety_throwing_copy<std::set>();
test_assoc_set_insert_range_exception_safety_throwing_allocator<std::set, int>();
+ 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/associative/set/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_rv.pass.cpp
index ec18c4379b58d..9b01722faadaa 100644
--- a/libcxx/test/std/containers/associative/set/insert_rv.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_rv.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// pair<iterator, bool> insert(value_type&& v);
+// constexpr pair<iterator, bool> insert(value_type&& v); // constexpr since C++26
#include <set>
#include <cassert>
@@ -21,7 +21,7 @@
#include "MoveOnly.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<MoveOnly> M;
typedef std::pair<M::iterator, bool> R;
@@ -79,5 +79,12 @@ int main(int, char**) {
assert(*r.first == 3);
}
+ 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/associative/set/iterator.pass.cpp b/libcxx/test/std/containers/associative/set/iterator.pass.cpp
index 1a18cbc426478..467d88e291a02 100644
--- a/libcxx/test/std/containers/associative/set/iterator.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/iterator.pass.cpp
@@ -10,20 +10,20 @@
// class set
-// iterator begin();
-// const_iterator begin() const;
-// iterator end();
-// const_iterator end() const;
+// constexpr iterator begin(); // constexpr since C++26
+// constexpr const_iterator begin() const; // constexpr since C++26
+// constexpr iterator end(); // constexpr since C++26
+// constexpr const_iterator end() const; // constexpr since C++26
//
-// reverse_iterator rbegin();
-// const_reverse_iterator rbegin() const;
-// reverse_iterator rend();
-// const_reverse_iterator rend() const;
+// constexpr reverse_iterator rbegin(); // constexpr since C++26
+// constexpr const_reverse_iterator rbegin() const; // constexpr since C++26
+// constexpr reverse_iterator rend(); // constexpr since C++26
+// constexpr const_reverse_iterator rend() const; // constexpr since C++26
//
-// const_iterator cbegin() const;
-// const_iterator cend() const;
-// const_reverse_iterator crbegin() const;
-// const_reverse_iterator crend() const;
+// constexpr const_iterator cbegin() const; // constexpr since C++26
+// constexpr const_iterator cend() const; // constexpr since C++26
+// constexpr const_reverse_iterator crbegin() const; // constexpr since C++26
+// constexpr const_reverse_iterator crend() const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -32,7 +32,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8};
@@ -129,5 +129,12 @@ 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/associative/set/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp
index 2f114685fb84d..dcaa3b17c8fcc 100644
--- a/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp
@@ -10,8 +10,8 @@
// class set
-// iterator lower_bound(const key_type& k);
-// const_iterator lower_bound(const key_type& k) const;
+// constexpr iterator lower_bound(const key_type& k); // constexpr since C++26
+// constexpr const_iterator lower_bound(const key_type& k) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "private_constructor.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -283,5 +283,12 @@ 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/associative/set/max_size.pass.cpp b/libcxx/test/std/containers/associative/set/max_size.pass.cpp
index b00d316c47b35..f11eda16312e5 100644
--- a/libcxx/test/std/containers/associative/set/max_size.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/max_size.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// size_type max_size() const;
+// constexpr size_type max_size() const; // constexpr since C++26
#include <cassert>
#include <limits>
@@ -20,7 +20,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::set<int, std::less<int>, A> C;
@@ -44,5 +44,12 @@ int main(int, char**) {
assert(c.max_size() <= alloc_max_size(c.get_allocator()));
}
+ return true;
+}
+int main(int, char**) {
+ test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
diff --git a/libcxx/test/std/containers/associative/set/merge.pass.cpp b/libcxx/test/std/containers/associative/set/merge.pass.cpp
index 50141d5444b1f..4c76c59ec5de5 100644
--- a/libcxx/test/std/containers/associative/set/merge.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/merge.pass.cpp
@@ -13,13 +13,13 @@
// class set
// template <class C2>
-// void merge(set<key_type, C2, allocator_type>& source);
+// constexpr void merge(set<key_type, C2, allocator_type>& source); // constexpr since C++26
// template <class C2>
-// void merge(set<key_type, C2, allocator_type>&& source);
+// constexpr void merge(set<key_type, C2, allocator_type>&& source); // constexpr since C++26
// template <class C2>
-// void merge(multiset<key_type, C2, allocator_type>& source);
+// constexpr void merge(multiset<key_type, C2, allocator_type>& source); // constexpr since C++26
// template <class C2>
-// void merge(multiset<key_type, C2, allocator_type>&& source);
+// constexpr void merge(multiset<key_type, C2, allocator_type>&& source); // constexpr since C++26
#include <set>
#include <cassert>
@@ -46,7 +46,7 @@ struct throw_comparator {
};
#endif
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::set<int> src{1, 3, 5};
std::set<int> dst{2, 4, 5};
@@ -134,5 +134,12 @@ int main(int, char**) {
first.merge(std::move(second));
}
}
+ 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/associative/set/set.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp
index 4321666044a3b..539d6e11e6b6f 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set(const allocator_type& a);
+// constexpr set(const allocator_type& a); // constexpr since C++26
#include <set>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "test_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef std::less<int> C;
typedef test_allocator<int> A;
std::set<int, C, A> m(A(5));
@@ -26,5 +26,12 @@ int main(int, char**) {
assert(m.begin() == m.end());
assert(m.get_allocator() == A(5));
+ 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/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
index d674669fd2559..1e0de1434aeb9 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set& operator=(initializer_list<value_type> il);
+// constexpr set& operator=(initializer_list<value_type> il); // constexpr since C++26
#include <set>
#include <cassert>
@@ -69,9 +69,16 @@ void duplicate_keys_test() {
LIBCPP_ASSERT(alloc_stats.alloc_count == 0);
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
basic_test();
duplicate_keys_test();
+ 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/associative/set/set.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp
index 03452142f5b85..5b3abfe1fcb3b 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// explicit set(const key_compare& comp) const;
+// constexpr explicit set(const key_compare& comp) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "../../../test_compare.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef test_less<int> C;
const std::set<int, C> m(C(3));
assert(m.empty());
@@ -26,5 +26,12 @@ int main(int, char**) {
assert(m.key_comp() == C(3));
assert(m.value_comp() == C(3));
+ 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/associative/set/set.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
index 2ae0547054537..ba358f1c95412 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set(const value_compare& comp, const allocator_type& a);
+// constexpr set(const value_compare& comp, const allocator_type& a); // constexpr since C++26
#include <set>
#include <cassert>
@@ -19,7 +19,7 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef test_less<int> C;
typedef test_allocator<int> A;
std::set<int, C, A> m(C(4), A(5));
@@ -28,5 +28,12 @@ int main(int, char**) {
assert(m.key_comp() == C(4));
assert(m.get_allocator() == A(5));
+ 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/associative/set/set.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
index 8fac335175c80..f2116c019d3b6 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set(const set& m);
+// constexpr set(const set& m); // constexpr since C++26
#include <cassert>
#include <set>
@@ -127,8 +127,15 @@ void test() {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test();
+ 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/associative/set/set.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
index 2784af65b0a0f..200bf71b5f3dd 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set(const set& m, const allocator_type& a);
+// constexpr set(const set& m, const allocator_type& a); // constexpr since C++26
#include <cassert>
#include <set>
@@ -99,8 +99,15 @@ void test() {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test();
+ 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/associative/set/set.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
index dd1dbc86190f8..7c301d62cb586 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set& operator=(const set& s);
+// constexpr set& operator=(const set& s); // constexpr since C++26
#include <algorithm>
#include <cassert>
@@ -277,8 +277,15 @@ void test() {
}
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test();
+ 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/associative/set/set.cons/deduct.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
index e26df4503ed41..56540fbf35c6a 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
@@ -37,6 +37,8 @@
// set(from_range_t, R&&, Allocator)
// -> set<ranges::range_value_t<R>, less<ranges::range_value_t<R>>, Allocator>; // C++23
+// constexpr since C++26
+
#include <algorithm> // std::equal
#include <array>
#include <cassert>
@@ -52,7 +54,7 @@ struct NotAnAllocator {
friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
const int arr[] = {1, 2, 1, INT_MAX, 3};
std::set s(std::begin(arr), std::end(arr));
@@ -212,5 +214,12 @@ int main(int, char**) {
AssociativeContainerDeductionGuidesSfinaeAway<std::set, std::set<int>>();
+ 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/associative/set/set.cons/default.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp
index c41d7c3b9d3bd..6ae5d003fef15 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// set();
+// constexpr set(); // constexpr since C++26
#include <set>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::set<int> m;
assert(m.empty());
@@ -51,5 +51,12 @@ 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/associative/set/set.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
index c01ac3b2fad0b..4b2ddd174519d 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
@@ -8,7 +8,7 @@
// <set>
-// set()
+// constexpr set() // constexpr since C++26
// noexcept(
// is_nothrow_default_constructible<allocator_type>::value &&
// is_nothrow_default_constructible<key_compare>::value &&
@@ -32,7 +32,7 @@ struct some_comp {
bool operator()(const T&, const T&) const { return false; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
#if defined(_LIBCPP_VERSION)
{
typedef std::set<MoveOnly> C;
@@ -52,5 +52,12 @@ int main(int, char**) {
static_assert(!std::is_nothrow_default_constructible<C>::value, "");
}
+ 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/associative/set/set.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
index 63c0433477414..15f3c257af272 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
@@ -8,7 +8,7 @@
// <set>
-// ~set() // implied noexcept;
+// constexpr ~set() // implied noexcept; // constexpr since C++26
// UNSUPPORTED: c++03
@@ -26,7 +26,7 @@ struct some_comp {
bool operator()(const T&, const T&) const { return false; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<MoveOnly> C;
static_assert(std::is_nothrow_destructible<C>::value, "");
@@ -46,5 +46,12 @@ int main(int, char**) {
}
#endif // _LIBCPP_VERSION
+ 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/associative/set/set.cons/from_range.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
index 3590b75065ad9..23a5136aafcf2 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
@@ -14,6 +14,7 @@
// template<container-compatible-range<value_type> R>
// set(from_range_t, R&& rg, const Allocator& a))
// : set(from_range, std::forward<R>(rg), Compare(), a) { } // C++23
+// constexpr since C++26
#include <array>
#include <set>
@@ -30,7 +31,7 @@ void test_duplicates() {
assert(std::ranges::is_permutation(expected, c));
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
for_all_iterators_and_allocators<int>([]<class Iter, class Sent, class Alloc>() {
test_associative_set<std::set, int, Iter, Sent, test_less<int>, Alloc>();
});
@@ -42,5 +43,12 @@ int main(int, char**) {
test_set_exception_safety_throwing_copy<std::set>();
test_set_exception_safety_throwing_allocator<std::set, int>();
+ 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/associative/set/set.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
index 48495712425be..974d2d96b02d7 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+// constexpr set(initializer_list<value_type> il, const key_compare& comp = key_compare()); // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<int> C;
typedef C::value_type V;
@@ -50,5 +50,12 @@ int main(int, char**) {
assert(*++i == V(6));
}
+ 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/associative/set/set.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
index 25684966078d6..3572465b9118e 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+// constexpr set(initializer_list<value_type> il, const key_compare& comp = key_compare()); // constexpr since C++26
#include <set>
#include <cassert>
@@ -21,7 +21,7 @@
#include "test_macros.h"
#include "../../../test_compare.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef test_less<int> Cmp;
typedef std::set<int, Cmp> C;
typedef C::value_type V;
@@ -37,5 +37,12 @@ int main(int, char**) {
assert(*++i == V(6));
assert(m.key_comp() == Cmp(10));
+ 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/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
index 48649c3b281f4..737e96bfad9f5 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
@@ -12,8 +12,8 @@
// class set
-// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
-// set(initializer_list<value_type> il, const allocator_type& a);
+// constexpr set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); // constexpr since C++26
+// constexpr set(initializer_list<value_type> il, const allocator_type& a); // constexpr since C++26
#include <set>
#include <cassert>
@@ -23,7 +23,7 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef test_less<int> Cmp;
typedef test_allocator<int> A;
@@ -60,5 +60,12 @@ int main(int, char**) {
assert(m.get_allocator() == A(4));
}
+ 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/associative/set/set.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
index 27a4e6a5f527d..4e49265811b19 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
@@ -11,7 +11,7 @@
// class set
// template <class InputIterator>
-// set(InputIterator first, InputIterator last);
+// constexpr set(InputIterator first, InputIterator last); // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "test_iterators.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
@@ -46,5 +46,12 @@ 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/associative/set/set.cons/iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
index dac553073f177..5a4c9d156a3b6 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
@@ -11,12 +11,12 @@
// class set
// template <class InputIterator>
-// set(InputIterator first, InputIterator last,
-// const value_compare& comp, const allocator_type& a);
+// constexpr set(InputIterator first, InputIterator last,
+// const value_compare& comp, const allocator_type& a); // constexpr since C++26
//
// template <class InputIterator>
-// set(InputIterator first, InputIterator last,
-// const allocator_type& a);
+// constexpr set(InputIterator first, InputIterator last,
+// const allocator_type& a); // constexpr since C++26
#include <set>
#include <cassert>
@@ -26,7 +26,7 @@
#include "../../../test_compare.h"
#include "test_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
@@ -63,5 +63,12 @@ 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/associative/set/set.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
index 573bbd316e073..204c86a62590e 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
@@ -11,7 +11,7 @@
// class set
// template <class InputIterator>
-// set(InputIterator first, InputIterator last, const value_compare& comp);
+// constexpr set(InputIterator first, InputIterator last, const value_compare& comp); // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "test_iterators.h"
#include "../../../test_compare.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef int V;
V ar[] = {1, 1, 1, 2, 2, 2, 3, 3, 3};
typedef test_less<V> C;
@@ -33,5 +33,12 @@ int main(int, char**) {
assert(*std::next(m.begin()) == 2);
assert(*std::next(m.begin(), 2) == 3);
+ 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/associative/set/set.cons/move.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
index 2c1ec22ab257d..a4e68ff583d01 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set(set&& s);
+// constexpr set(set&& s); // constexpr since C++26
#include <set>
#include <cassert>
@@ -22,7 +22,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef test_less<int> C;
@@ -82,5 +82,12 @@ int main(int, char**) {
assert(std::distance(mo.begin(), mo.end()) == 0);
}
+ 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/associative/set/set.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
index c85463bd391ca..4f15202f2ca83 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set(set&& s, const allocator_type& a);
+// constexpr set(set&& s, const allocator_type& a); // constexpr since C++26
#include <set>
#include <cassert>
@@ -24,7 +24,7 @@
#include "test_allocator.h"
#include "Counter.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef MoveOnly V;
typedef test_less<MoveOnly> C;
@@ -111,5 +111,12 @@ int main(int, char**) {
assert(Counter_base::gConstructed == 0);
}
+ 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/associative/set/set.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
index bacd58c172a12..418c4d06ca114 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -12,7 +12,7 @@
// class set
-// set& operator=(set&& s);
+// constexpr set& operator=(set&& s); // constexpr since C++26
#include <set>
#include <cassert>
@@ -23,7 +23,7 @@
#include "test_allocator.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef MoveOnly V;
typedef test_less<MoveOnly> C;
@@ -93,5 +93,12 @@ int main(int, char**) {
assert(m1.empty());
}
+ 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/associative/set/set.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
index 9325b8d1f40de..fa315e392ce0c 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
@@ -8,9 +8,9 @@
// <set>
-// set(set&&)
+// constexpr set(set&&)
// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
-// is_nothrow_move_constructible<key_compare>::value);
+// is_nothrow_move_constructible<key_compare>::value); // constexpr since C++26
// This tests a conforming extension
@@ -30,7 +30,7 @@ struct some_comp {
bool operator()(const T&, const T&) const { return false; }
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
#if defined(_LIBCPP_VERSION)
{
typedef std::set<MoveOnly> C;
@@ -50,5 +50,12 @@ int main(int, char**) {
static_assert(!std::is_nothrow_move_constructible<C>::value, "");
}
+ 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/associative/set/set.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
index b076b31059610..978e80821eb49 100644
--- a/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
@@ -11,7 +11,7 @@
// template <class T, class Compare, class Allocator, class Predicate>
// typename set<T, Compare, Allocator>::size_type
-// erase_if(set<T, Compare, Allocator>& c, Predicate pred);
+// constexpr erase_if(set<T, Compare, Allocator>& c, Predicate pred); // constexpr since C++26
#include <set>
@@ -53,7 +53,7 @@ void test() {
test0(S({1, 2, 3}), False, S({1, 2, 3}), 0);
}
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
test<std::set<int>>();
test<std::set<int, std::less<int>, min_allocator<int>>>();
test<std::set<int, std::less<int>, test_allocator<int>>>();
@@ -61,5 +61,12 @@ int main(int, char**) {
test<std::set<long>>();
test<std::set<double>>();
+ 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/associative/set/set.nonmember/compare.three_way.pass.cpp b/libcxx/test/std/containers/associative/set/set.nonmember/compare.three_way.pass.cpp
index dc513d96e5ba8..563a8c12db828 100644
--- a/libcxx/test/std/containers/associative/set/set.nonmember/compare.three_way.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.nonmember/compare.three_way.pass.cpp
@@ -12,16 +12,23 @@
// class set
// template<class Key, class Compare, class Allocator>
-// synth-three-way-result<Key> operator<=>(const set<Key, Compare, Allocator>& x,
-// const set<Key, Compare, Allocator>& y);
+// constexpr synth-three-way-result<Key> operator<=>(const set<Key, Compare, Allocator>& x,
+// const set<Key, Compare, Allocator>& y); // constexpr since C++26
#include <cassert>
#include <set>
#include "test_container_comparisons.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
assert((test_ordered_set_container_spaceship<std::set>()));
// `std::set` is not constexpr, so no `static_assert` test here.
+ 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/associative/set/set.nonmember/op_compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
index 1be07ce885298..547cc59c51880 100644
--- a/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.nonmember/op_compare.pass.cpp
@@ -9,28 +9,28 @@
// <set>
// template<class Key, class Compare, class Alloc>
-// bool operator==(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator==(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
//
// template<class Key, class Compare, class Alloc>
-// bool operator!=(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator!=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
//
// template<class Key, class Compare, class Alloc>
-// bool operator<(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator<(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
//
// template<class Key, class Compare, class Alloc>
-// bool operator>(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator>(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
//
// template<class Key, class Compare, class Alloc>
-// bool operator<=(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator<=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
//
// template<class Key, class Compare, class Alloc>
-// bool operator>=(const std::set<Key, Compare, Alloc>& lhs,
-// const std::set<Key, Compare, Alloc>& rhs);
+// constexpr bool operator>=(const std::set<Key, Compare, Alloc>& lhs,
+// const std::set<Key, Compare, Alloc>& rhs); // constexpr since C++26
#include <set>
#include <cassert>
@@ -38,7 +38,7 @@
#include "test_comparisons.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
std::set<int> s1, s2;
s1.insert(1);
@@ -61,5 +61,12 @@ int main(int, char**) {
const std::set<int>&cs1 = s1, cs2 = s2;
assert(testComparisons(cs1, cs2, false, true));
}
+ 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/associative/set/set.observers/comp.pass.cpp b/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
index 019dae3955acb..9aef8c7cce41b 100644
--- a/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
@@ -8,13 +8,13 @@
// <set>
-// key_compare key_comp() const;
-// value_compare value_comp() const;
+// constexpr key_compare key_comp() const; // constexpr since C++26
+// constexpr value_compare value_comp() const; // constexpr since C++26
#include <set>
#include <cassert>
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef std::set<int> set_type;
set_type s;
@@ -29,5 +29,12 @@ int main(int, char**) {
assert(cs.value_comp()(*p1.first, *p2.first));
assert(!cs.value_comp()(*p2.first, *p1.first));
+ 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/associative/set/set.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp
index db3dc9831b3dd..5a5a5156ce652 100644
--- a/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// void swap(set& m);
+// constexpr void swap(set& m); // constexpr since C++26
#include <set>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -110,5 +110,12 @@ 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/associative/set/set.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
index e663a67035ff5..24fb007ef266e 100644
--- a/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// void swap(set& m);
+// constexpr void swap(set& m); // constexpr since C++26
#include <set>
#include <cassert>
@@ -18,7 +18,7 @@
#include "test_allocator.h"
#include "../../../test_compare.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
typedef int V;
{
typedef std::set<int> M;
@@ -100,5 +100,12 @@ int main(int, char**) {
assert(m2.get_allocator() == A(1));
}
+ 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/associative/set/set.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
index 36ab989b76043..4c4bf48adf241 100644
--- a/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
@@ -10,7 +10,7 @@
// <set>
-// void swap(set& c)
+// constexpr void swap(set& c) // constexpr since C++26
// noexcept(!allocator_type::propagate_on_container_swap::value ||
// __is_nothrow_swappable<allocator_type>::value);
//
@@ -86,7 +86,7 @@ struct some_alloc3 {
typedef std::false_type is_always_equal;
};
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<MoveOnly> C;
static_assert(noexcept(swap(std::declval<C&>(), std::declval<C&>())), "");
@@ -131,5 +131,12 @@ int main(int, char**) {
# endif // _LIBCPP_VERSION
#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/associative/set/size.pass.cpp b/libcxx/test/std/containers/associative/set/size.pass.cpp
index 1672e1f055c6c..58084634e8dde 100644
--- a/libcxx/test/std/containers/associative/set/size.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/size.pass.cpp
@@ -10,7 +10,7 @@
// class set
-// size_type size() const;
+// constexpr size_type size() const; // constexpr since C++26
#include <set>
#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::set<int> M;
M m;
@@ -56,5 +56,12 @@ 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/associative/set/types.pass.cpp b/libcxx/test/std/containers/associative/set/types.pass.cpp
index a7c30244a540b..af3915dccf1fa 100644
--- a/libcxx/test/std/containers/associative/set/types.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/types.pass.cpp
@@ -34,7 +34,7 @@
#include "test_macros.h"
#include "min_allocator.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef std::set<int> C;
static_assert((std::is_same<C::key_type, int>::value), "");
@@ -67,5 +67,12 @@ 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/associative/set/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp
index 3543879e07940..f5825c30519e6 100644
--- a/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp
@@ -10,8 +10,8 @@
// class set
-// iterator upper_bound(const key_type& k);
-// const_iterator upper_bound(const key_type& k) const;
+// constexpr iterator upper_bound(const key_type& k); // constexpr since C++26
+// constexpr const_iterator upper_bound(const key_type& k) const; // constexpr since C++26
#include <set>
#include <cassert>
@@ -20,7 +20,7 @@
#include "min_allocator.h"
#include "private_constructor.h"
-int main(int, char**) {
+TEST_CONSTEXPR_CXX26 bool test() {
{
typedef int V;
typedef std::set<int> M;
@@ -283,5 +283,12 @@ int main(int, char**) {
}
#endif
+ return true;
+}
+int main(int, char**) {
+ test();
+#if TEST_STD_VER >= 26
+ static_assert(test());
+#endif
return 0;
}
>From 594dff9a2ed3b45b1140c5df09a4e149d8afac7e Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 15:56:56 -0500
Subject: [PATCH 3/9] Get ready for set.cons
---
libcxx/include/__tree | 2 +-
libcxx/include/set | 234 ++++++++++++++++++++++++++----------------
2 files changed, 144 insertions(+), 92 deletions(-)
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 5398ff911ec57..5f4c317d62291 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -1467,7 +1467,7 @@ private:
}
template <class _To, class _From, class _ValueT = _Tp, __enable_if_t<!__is_tree_value_type_v<_ValueT>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI static void __assign_value(_To& __lhs, _From&& __rhs) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static void __assign_value(_To& __lhs, _From&& __rhs) {
__lhs = std::forward<_From>(__rhs);
}
diff --git a/libcxx/include/set b/libcxx/include/set
index d58b6e96b061d..d66a54e964a01 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -10,6 +10,8 @@
#ifndef _LIBCPP_SET
#define _LIBCPP_SET
+// TODO: add constexpr everywhere
+
/*
set synopsis
@@ -614,24 +616,27 @@ public:
template <class _Key2, class _Compare2, class _Alloc2>
friend class multiset;
- _LIBCPP_HIDE_FROM_ABI set() _NOEXCEPT_(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set() _NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_default_constructible<key_compare>::value&&
is_nothrow_copy_constructible<key_compare>::value)
: __tree_(value_compare()) {}
- _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp) _NOEXCEPT_(
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const value_compare& __comp) _NOEXCEPT_(
is_nothrow_default_constructible<allocator_type>::value&& is_nothrow_copy_constructible<key_compare>::value)
: __tree_(__comp) {}
- _LIBCPP_HIDE_FROM_ABI explicit set(const value_compare& __comp, const allocator_type& __a) : __tree_(__comp, __a) {}
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const value_compare& __comp, const allocator_type& __a)
+ : __tree_(__comp, __a) {}
template <class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ set(_InputIterator __f, _InputIterator __l, const value_compare& __comp = value_compare())
: __tree_(__comp) {
insert(__f, __l);
}
template <class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
set(_InputIterator __f, _InputIterator __l, const value_compare& __comp, const allocator_type& __a)
: __tree_(__comp, __a) {
insert(__f, __l);
@@ -639,7 +644,7 @@ public:
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
set(from_range_t,
_Range&& __range,
const key_compare& __comp = key_compare(),
@@ -651,205 +656,247 @@ public:
# if _LIBCPP_STD_VER >= 14
template <class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 set(_InputIterator __f, _InputIterator __l, const allocator_type& __a)
: set(__f, __l, key_compare(), __a) {}
# endif
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI set(from_range_t, _Range&& __range, const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(from_range_t, _Range&& __range, const allocator_type& __a)
: set(from_range, std::forward<_Range>(__range), key_compare(), __a) {}
# endif
- _LIBCPP_HIDE_FROM_ABI set(const set& __s) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(const set& __s) = default;
- _LIBCPP_HIDE_FROM_ABI set& operator=(const set& __s) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(const set& __s) = default;
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI set(set&& __s) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(set&& __s) = default;
# endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI explicit set(const allocator_type& __a) : __tree_(__a) {}
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit set(const allocator_type& __a) : __tree_(__a) {}
- _LIBCPP_HIDE_FROM_ABI set(const set& __s, const allocator_type& __a) : __tree_(__s.__tree_.value_comp(), __a) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(const set& __s, const allocator_type& __a)
+ : __tree_(__s.__tree_.value_comp(), __a) {
insert(__s.begin(), __s.end());
}
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI set(set&& __s, const allocator_type& __a);
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(set&& __s, const allocator_type& __a);
- _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ set(initializer_list<value_type> __il, const value_compare& __comp = value_compare())
: __tree_(__comp) {
insert(__il.begin(), __il.end());
}
- _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26
+ set(initializer_list<value_type> __il, const value_compare& __comp, const allocator_type& __a)
: __tree_(__comp, __a) {
insert(__il.begin(), __il.end());
}
# if _LIBCPP_STD_VER >= 14
- _LIBCPP_HIDE_FROM_ABI set(initializer_list<value_type> __il, const allocator_type& __a)
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set(initializer_list<value_type> __il, const allocator_type& __a)
: set(__il, key_compare(), __a) {}
# endif
- _LIBCPP_HIDE_FROM_ABI set& operator=(initializer_list<value_type> __il) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(initializer_list<value_type> __il) {
__tree_.__assign_unique(__il.begin(), __il.end());
return *this;
}
- _LIBCPP_HIDE_FROM_ABI set& operator=(set&& __s) = default;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 set& operator=(set&& __s) = default;
# endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI ~set() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~set() {
+ static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
- _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return __tree_.begin(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
- _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return __tree_.end(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return __tree_.end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator begin() _NOEXCEPT { return __tree_.begin(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator begin() const _NOEXCEPT { return __tree_.begin(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator end() _NOEXCEPT { return __tree_.end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator end() const _NOEXCEPT { return __tree_.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 _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rbegin() _NOEXCEPT {
+ return reverse_iterator(end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rbegin() const _NOEXCEPT {
+ return const_reverse_iterator(end());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reverse_iterator rend() _NOEXCEPT {
+ return reverse_iterator(begin());
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator rend() const _NOEXCEPT {
+ return const_reverse_iterator(begin());
+ }
- _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); }
- _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); }
- _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cbegin() const _NOEXCEPT { return begin(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator cend() const _NOEXCEPT { return end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crbegin() const _NOEXCEPT {
+ return rbegin();
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_reverse_iterator crend() const _NOEXCEPT { return rend(); }
- [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return __tree_.size() == 0; }
- _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return __tree_.size(); }
- _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return __tree_.max_size(); }
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool empty() const _NOEXCEPT {
+ return __tree_.size() == 0;
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type size() const _NOEXCEPT { return __tree_.size(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type max_size() const _NOEXCEPT {
+ return __tree_.max_size();
+ }
// modifiers:
# ifndef _LIBCPP_CXX03_LANG
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> emplace(_Args&&... __args) {
return __tree_.__emplace_unique(std::forward<_Args>(__args)...);
}
template <class... _Args>
- _LIBCPP_HIDE_FROM_ABI iterator emplace_hint(const_iterator __p, _Args&&... __args) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace_hint(const_iterator __p, _Args&&... __args) {
return __tree_.__emplace_hint_unique(__p, std::forward<_Args>(__args)...).first;
}
# endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(const value_type& __v) { return __tree_.__emplace_unique(__v); }
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(const value_type& __v) {
+ return __tree_.__emplace_unique(__v);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) {
return __tree_.__emplace_hint_unique(__p, __v).first;
}
template <class _InputIterator>
- _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __first, _InputIterator __last) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __first, _InputIterator __last) {
__tree_.__insert_range_unique(__first, __last);
}
# if _LIBCPP_STD_VER >= 23
template <_ContainerCompatibleRange<value_type> _Range>
- _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) {
__tree_.__insert_range_unique(ranges::begin(__range), ranges::end(__range));
}
# endif
# ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI pair<iterator, bool> insert(value_type&& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool> insert(value_type&& __v) {
return __tree_.__emplace_unique(std::move(__v));
}
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, value_type&& __v) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, value_type&& __v) {
return __tree_.__emplace_hint_unique(__p, std::move(__v)).first;
}
- _LIBCPP_HIDE_FROM_ABI void insert(initializer_list<value_type> __il) { insert(__il.begin(), __il.end()); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list<value_type> __il) {
+ insert(__il.begin(), __il.end());
+ }
# endif // _LIBCPP_CXX03_LANG
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p); }
- _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_unique(__k); }
- _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f, __l); }
- _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) { return __tree_.erase(__p); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) {
+ return __tree_.__erase_unique(__k);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) {
+ return __tree_.erase(__f, __l);
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); }
# if _LIBCPP_STD_VER >= 17
- _LIBCPP_HIDE_FROM_ABI insert_return_type insert(node_type&& __nh) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 insert_return_type insert(node_type&& __nh) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
"node_type with incompatible allocator passed to set::insert()");
return __tree_.template __node_handle_insert_unique< node_type, insert_return_type>(std::move(__nh));
}
- _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __hint, node_type&& __nh) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __hint, node_type&& __nh) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(),
"node_type with incompatible allocator passed to set::insert()");
return __tree_.template __node_handle_insert_unique<node_type>(__hint, std::move(__nh));
}
- _LIBCPP_HIDE_FROM_ABI node_type extract(key_type const& __key) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(key_type const& __key) {
return __tree_.template __node_handle_extract<node_type>(__key);
}
- _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 node_type extract(const_iterator __it) {
return __tree_.template __node_handle_extract<node_type>(__it);
}
template <class _Compare2>
- _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>& __source) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>& __source) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
__tree_.__node_handle_merge_unique(__source.__tree_);
}
template <class _Compare2>
- _LIBCPP_HIDE_FROM_ABI void merge(set<key_type, _Compare2, allocator_type>&& __source) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void merge(set<key_type, _Compare2, allocator_type>&& __source) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
__tree_.__node_handle_merge_unique(__source.__tree_);
}
template <class _Compare2>
- _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>& __source) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ merge(multiset<key_type, _Compare2, allocator_type>& __source) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
__tree_.__node_handle_merge_unique(__source.__tree_);
}
template <class _Compare2>
- _LIBCPP_HIDE_FROM_ABI void merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+ merge(multiset<key_type, _Compare2, allocator_type>&& __source) {
_LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(
__source.get_allocator() == get_allocator(), "merging container with incompatible allocator");
__tree_.__node_handle_merge_unique(__source.__tree_);
}
# endif
- _LIBCPP_HIDE_FROM_ABI void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__s.__tree_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(set& __s) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) {
+ __tree_.swap(__s.__tree_);
+ }
- _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return __tree_.__alloc(); }
- _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp(); }
- _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return __tree_.value_comp(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT {
+ return __tree_.__alloc();
+ }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { return __tree_.value_comp(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { return __tree_.value_comp(); }
// set operations:
- _LIBCPP_HIDE_FROM_ABI iterator find(const key_type& __k) { return __tree_.find(__k); }
- _LIBCPP_HIDE_FROM_ABI const_iterator find(const key_type& __k) const { return __tree_.find(__k); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const key_type& __k) { return __tree_.find(__k); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const key_type& __k) const {
+ return __tree_.find(__k);
+ }
# if _LIBCPP_STD_VER >= 14
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI iterator find(const _K2& __k) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator find(const _K2& __k) {
return __tree_.find(__k);
}
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI const_iterator find(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator find(const _K2& __k) const {
return __tree_.find(__k);
}
# endif
- _LIBCPP_HIDE_FROM_ABI size_type count(const key_type& __k) const { return __tree_.__count_unique(__k); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const {
+ return __tree_.__count_unique(__k);
+ }
# if _LIBCPP_STD_VER >= 14
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI size_type count(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const _K2& __k) const {
return __tree_.__count_multi(__k);
}
# endif
# if _LIBCPP_STD_VER >= 20
- _LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __k) const { return find(__k) != end(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const key_type& __k) const {
+ return find(__k) != end();
+ }
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI bool contains(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool contains(const _K2& __k) const {
return find(__k) != end();
}
# endif // _LIBCPP_STD_VER >= 20
- _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const key_type& __k) { return __tree_.__lower_bound_unique(__k); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) {
+ return __tree_.__lower_bound_unique(__k);
+ }
- _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __k) const {
return __tree_.__lower_bound_unique(__k);
}
@@ -857,46 +904,50 @@ public:
// match multiple elements.
# if _LIBCPP_STD_VER >= 14
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI iterator lower_bound(const _K2& __k) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const _K2& __k) {
return __tree_.__lower_bound_multi(__k);
}
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const _K2& __k) const {
return __tree_.__lower_bound_multi(__k);
}
# endif
- _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.__upper_bound_unique(__k); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) {
+ return __tree_.__upper_bound_unique(__k);
+ }
- _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __k) const {
return __tree_.__upper_bound_unique(__k);
}
# if _LIBCPP_STD_VER >= 14
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const _K2& __k) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const _K2& __k) {
return __tree_.__upper_bound_multi(__k);
}
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const _K2& __k) const {
return __tree_.__upper_bound_multi(__k);
}
# endif
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const key_type& __k) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const key_type& __k) {
return __tree_.__equal_range_unique(__k);
}
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const key_type& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ equal_range(const key_type& __k) const {
return __tree_.__equal_range_unique(__k);
}
# if _LIBCPP_STD_VER >= 14
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI pair<iterator, iterator> equal_range(const _K2& __k) {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, iterator> equal_range(const _K2& __k) {
return __tree_.__equal_range_multi(__k);
}
template <typename _K2, enable_if_t<__is_transparent_v<_Compare, _K2>, int> = 0>
- _LIBCPP_HIDE_FROM_ABI pair<const_iterator, const_iterator> equal_range(const _K2& __k) const {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<const_iterator, const_iterator>
+ equal_range(const _K2& __k) const {
return __tree_.__equal_range_multi(__k);
}
# endif
@@ -949,7 +1000,8 @@ set(initializer_list<_Key>, _Allocator) -> set<_Key, less<_Key>, _Allocator>;
# ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
-set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __tree_(std::move(__s.__tree_), __a) {
+_LIBCPP_CONSTEXPR_SINCE_CXX26 set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a)
+ : __tree_(std::move(__s.__tree_), __a) {
if (__a != __s.get_allocator()) {
const_iterator __e = cend();
while (!__s.empty())
@@ -960,7 +1012,7 @@ set<_Key, _Compare, _Allocator>::set(set&& __s, const allocator_type& __a) : __t
# endif // _LIBCPP_CXX03_LANG
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return __x.size() == __y.size() && std::equal(__x.begin(), __x.end(), __y.begin());
}
@@ -968,31 +1020,31 @@ operator==(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
# if _LIBCPP_STD_VER <= 17
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator<(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator!=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return !(__x == __y);
}
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return __y < __x;
}
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator>=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return !(__x < __y);
}
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI bool
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool
operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return !(__y < __x);
}
@@ -1000,7 +1052,7 @@ operator<=(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare,
# else // _LIBCPP_STD_VER <= 17
template <class _Key, class _Compare, class _Allocator>
-_LIBCPP_HIDE_FROM_ABI __synth_three_way_result<_Key>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __synth_three_way_result<_Key>
operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare, _Allocator>& __y) {
return std::lexicographical_compare_three_way(__x.begin(), __x.end(), __y.begin(), __y.end(), std::__synth_three_way);
}
@@ -1009,14 +1061,14 @@ operator<=>(const set<_Key, _Compare, _Allocator>& __x, const set<_Key, _Compare
// specialized algorithms:
template <class _Key, class _Compare, class _Allocator>
-inline _LIBCPP_HIDE_FROM_ABI void swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y)
- _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void
+swap(set<_Key, _Compare, _Allocator>& __x, set<_Key, _Compare, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) {
__x.swap(__y);
}
# if _LIBCPP_STD_VER >= 20
template <class _Key, class _Compare, class _Allocator, class _Predicate>
-inline _LIBCPP_HIDE_FROM_ABI typename set<_Key, _Compare, _Allocator>::size_type
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 typename set<_Key, _Compare, _Allocator>::size_type
erase_if(set<_Key, _Compare, _Allocator>& __c, _Predicate __pred) {
return std::__libcpp_erase_if_container(__c, __pred);
}
>From f29268adce636381be9409c5c01c92281c537865 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 15:58:10 -0500
Subject: [PATCH 4/9] Test set.cons
---
.../from_range_associative_containers.h | 14 ++++-----
.../set.cons/assign_initializer_list.pass.cpp | 4 +--
.../associative/set/set.cons/copy.pass.cpp | 8 ++---
.../set/set.cons/copy_alloc.pass.cpp | 8 ++---
.../set/set.cons/copy_assign.pass.cpp | 31 +++++++++----------
.../associative/set/set.cons/deduct.pass.cpp | 2 +-
.../set/set.cons/from_range.pass.cpp | 3 +-
.../set/set.cons/move_alloc.pass.cpp | 2 +-
.../test/std/containers/from_range_helpers.h | 4 +--
9 files changed, 33 insertions(+), 43 deletions(-)
diff --git a/libcxx/test/std/containers/associative/from_range_associative_containers.h b/libcxx/test/std/containers/associative/from_range_associative_containers.h
index cb3646d738968..2a391b50fc06a 100644
--- a/libcxx/test/std/containers/associative/from_range_associative_containers.h
+++ b/libcxx/test/std/containers/associative/from_range_associative_containers.h
@@ -189,7 +189,7 @@ constexpr bool test_set_constraints() {
}
template <template <class...> class Container, class T, class Iter, class Sent, class Comp, class Alloc>
-void test_associative_set_with_input(std::vector<T>&& input) {
+TEST_CONSTEXPR_CXX26 void test_associative_set_with_input(std::vector<T>&& input) {
{ // (range)
std::ranges::subrange in(Iter(input.data()), Sent(Iter(input.data() + input.size())));
Container<T> c(std::from_range, in);
@@ -232,7 +232,7 @@ void test_associative_set_with_input(std::vector<T>&& input) {
}
template <template <class...> class Container, class T, class Iter, class Sent, class Comp, class Alloc>
-void test_associative_set() {
+TEST_CONSTEXPR_CXX26 void test_associative_set() {
auto test_with_input = &test_associative_set_with_input<Container, T, Iter, Sent, Comp, Alloc>;
// Normal input.
@@ -244,7 +244,7 @@ void test_associative_set() {
}
template <template <class...> class Container>
-void test_associative_set_move_only() {
+TEST_CONSTEXPR_CXX26 void test_associative_set_move_only() {
MoveOnly input[5];
std::ranges::subrange in(std::move_iterator{input}, std::move_iterator{input + 5});
@@ -252,8 +252,8 @@ void test_associative_set_move_only() {
}
template <template <class...> class Container>
-void test_set_exception_safety_throwing_copy() {
-#if !defined(TEST_HAS_NO_EXCEPTIONS)
+TEST_CONSTEXPR_CXX26 void test_set_exception_safety_throwing_copy() {
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(TEST_IS_CONSTANT_EVALUATED)
using T = ThrowingCopy<3>;
T::reset();
T in[5] = {{1}, {2}, {3}, {4}, {5}};
@@ -270,8 +270,8 @@ void test_set_exception_safety_throwing_copy() {
}
template <template <class...> class Container, class T>
-void test_set_exception_safety_throwing_allocator() {
-#if !defined(TEST_HAS_NO_EXCEPTIONS)
+TEST_CONSTEXPR_CXX26 void test_set_exception_safety_throwing_allocator() {
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(TEST_IS_CONSTANT_EVALUATED)
T in[] = {1, 2};
try {
diff --git a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
index 1e0de1434aeb9..c37e2f400db3e 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -21,7 +21,7 @@
#include "min_allocator.h"
#include "test_allocator.h"
-void basic_test() {
+TEST_CONSTEXPR_CXX26 void basic_test() {
{
typedef std::set<int> C;
typedef C::value_type V;
@@ -54,7 +54,7 @@ void basic_test() {
}
}
-void duplicate_keys_test() {
+TEST_CONSTEXPR_CXX26 void duplicate_keys_test() {
test_allocator_statistics alloc_stats;
typedef std::set<int, std::less<int>, test_allocator<int> > Set;
{
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
index f2116c019d3b6..ea4a34940bacd 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
@@ -20,7 +20,7 @@
#include "test_allocator.h"
template <template <class> class Alloc>
-void test_alloc() {
+TEST_CONSTEXPR_CXX26 void test_alloc() {
{ // Simple check
using Set = std::set<int, std::less<int>, Alloc<int> >;
@@ -79,7 +79,7 @@ void test_alloc() {
}
}
-void test() {
+TEST_CONSTEXPR_CXX26 bool test() {
test_alloc<std::allocator>();
test_alloc<min_allocator>(); // Make sure that fancy pointers work
@@ -125,10 +125,6 @@ void test() {
assert(orig.size() == 3);
assert(orig.get_allocator() == other_allocator<int>(10));
}
-}
-
-TEST_CONSTEXPR_CXX26 bool test() {
- test();
return true;
}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
index 200bf71b5f3dd..bb1d251777904 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
@@ -21,7 +21,7 @@
#include "test_allocator.h"
template <class Alloc>
-void test_alloc(const Alloc& new_alloc) {
+TEST_CONSTEXPR_CXX26 void test_alloc(const Alloc& new_alloc) {
{ // Simple check
using Set = std::set<int, std::less<int>, Alloc>;
@@ -81,7 +81,7 @@ void test_alloc(const Alloc& new_alloc) {
}
}
-void test() {
+TEST_CONSTEXPR_CXX26 bool test() {
test_alloc(std::allocator<int>());
test_alloc(test_allocator<int>(25)); // Make sure that the new allocator is actually used
test_alloc(min_allocator<int>()); // Make sure that fancy pointers work
@@ -97,10 +97,6 @@ void test() {
assert(orig.size() == 3);
assert(orig.key_comp() == test_less<int>(3));
}
-}
-
-TEST_CONSTEXPR_CXX26 bool test() {
- test();
return true;
}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
index 7c301d62cb586..2e47297ccf28e 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -35,41 +35,42 @@ class tracking_allocator {
using value_type = T;
using propagate_on_container_copy_assignment = std::true_type;
- tracking_allocator(std::vector<void*>& allocs) : allocs_(&allocs) {}
+ TEST_CONSTEXPR_CXX26 tracking_allocator(std::vector<void*>& allocs) : allocs_(&allocs) {}
template <class U>
- tracking_allocator(const tracking_allocator<U>& other) : allocs_(other.allocs_) {}
+ TEST_CONSTEXPR_CXX26 tracking_allocator(const tracking_allocator<U>& other) : allocs_(other.allocs_) {}
- T* allocate(std::size_t n) {
+ TEST_CONSTEXPR_CXX26 T* allocate(std::size_t n) {
T* allocation = std::allocator<T>().allocate(n);
allocs_->push_back(allocation);
return allocation;
}
- void deallocate(T* ptr, std::size_t n) TEST_NOEXCEPT {
+ TEST_CONSTEXPR_CXX26 void deallocate(T* ptr, std::size_t n) TEST_NOEXCEPT {
auto res = std::remove(allocs_->begin(), allocs_->end(), ptr);
assert(res != allocs_->end() && "Trying to deallocate memory from different allocator?");
allocs_->erase(res);
std::allocator<T>().deallocate(ptr, n);
}
- friend bool operator==(const tracking_allocator& lhs, const tracking_allocator& rhs) {
+ TEST_CONSTEXPR_CXX26 friend bool operator==(const tracking_allocator& lhs, const tracking_allocator& rhs) {
return lhs.allocs_ == rhs.allocs_;
}
- friend bool operator!=(const tracking_allocator& lhs, const tracking_allocator& rhs) {
+ TEST_CONSTEXPR_CXX26 friend bool operator!=(const tracking_allocator& lhs, const tracking_allocator& rhs) {
return lhs.allocs_ != rhs.allocs_;
}
};
struct NoOp {
- void operator()() {}
+ TEST_CONSTEXPR_CXX26 void operator()() {}
};
template <class Alloc, class AllocatorInvariant = NoOp>
-void test_alloc(const Alloc& lhs_alloc = Alloc(),
- const Alloc& rhs_alloc = Alloc(),
- AllocatorInvariant check_alloc_invariant = NoOp()) {
+TEST_CONSTEXPR_CXX26 void
+test_alloc(const Alloc& lhs_alloc = Alloc(),
+ const Alloc& rhs_alloc = Alloc(),
+ AllocatorInvariant check_alloc_invariant = NoOp()) {
{ // Test empty/non-empty set combinations
{ // assign from a non-empty container into an empty one
using Set = std::set<int, std::less<int>, Alloc>;
@@ -236,7 +237,7 @@ void test_alloc(const Alloc& lhs_alloc = Alloc(),
}
}
-void test() {
+TEST_CONSTEXPR_CXX26 bool test() {
test_alloc<std::allocator<int> >();
#if TEST_STD_VER >= 11
test_alloc<min_allocator<int> >();
@@ -248,10 +249,10 @@ void test() {
std::vector<void*>* rhs_allocs_;
public:
- AssertEmpty(std::vector<void*>& lhs_allocs, std::vector<void*>& rhs_allocs)
+ TEST_CONSTEXPR_CXX26 AssertEmpty(std::vector<void*>& lhs_allocs, std::vector<void*>& rhs_allocs)
: lhs_allocs_(&lhs_allocs), rhs_allocs_(&rhs_allocs) {}
- void operator()() {
+ TEST_CONSTEXPR_CXX26 void operator()() {
assert(lhs_allocs_->empty());
assert(rhs_allocs_->empty());
}
@@ -275,10 +276,6 @@ void test() {
assert(orig.size() == 3);
assert(orig.key_comp() == test_less<int>(3));
}
-}
-
-TEST_CONSTEXPR_CXX26 bool test() {
- test();
return true;
}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
index 56540fbf35c6a..6de41997d424d 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/deduct.pass.cpp
@@ -51,7 +51,7 @@
#include "test_allocator.h"
struct NotAnAllocator {
- friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
+ TEST_CONSTEXPR_CXX26 friend bool operator<(NotAnAllocator, NotAnAllocator) { return false; }
};
TEST_CONSTEXPR_CXX26 bool test() {
diff --git a/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
index 23a5136aafcf2..d24cc95d69469 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/from_range.pass.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=2147483647
// template<container-compatible-range<value_type> R>
// set(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23
@@ -22,7 +23,7 @@
#include "../../from_range_associative_containers.h"
#include "test_macros.h"
-void test_duplicates() {
+TEST_CONSTEXPR_CXX26 void test_duplicates() {
using T = KeyValue;
std::array input = {T{1, 'a'}, T{2, 'a'}, T{3, 'a'}, T{3, 'b'}, T{3, 'c'}, T{2, 'b'}, T{4, 'a'}};
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
index 4f15202f2ca83..948cc85e7552d 100644
--- a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -73,7 +73,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(m3.key_comp() == C(5));
LIBCPP_ASSERT(m1.empty());
}
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
typedef Counter<int> V;
typedef std::less<V> C;
typedef test_allocator<V> A;
diff --git a/libcxx/test/std/containers/from_range_helpers.h b/libcxx/test/std/containers/from_range_helpers.h
index edf1d6ce528d7..13bd74d15cf14 100644
--- a/libcxx/test/std/containers/from_range_helpers.h
+++ b/libcxx/test/std/containers/from_range_helpers.h
@@ -54,8 +54,8 @@ struct KeyValue {
int key; // Only the key is considered for equality comparison.
char value; // Allows distinguishing equivalent instances.
- bool operator<(const KeyValue& other) const { return key < other.key; }
- bool operator==(const KeyValue& other) const { return key == other.key; }
+ TEST_CONSTEXPR_CXX26 bool operator<(const KeyValue& other) const { return key < other.key; }
+ TEST_CONSTEXPR_CXX26 bool operator==(const KeyValue& other) const { return key == other.key; }
};
template <>
>From b2e088aa09088fd8d263a92547797a297a103917 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 16:15:59 -0500
Subject: [PATCH 5/9] Test set.erasure
---
.../containers/associative/set/set.erasure/erase_if.pass.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
index 978e80821eb49..a5b2c741e02e4 100644
--- a/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.erasure/erase_if.pass.cpp
@@ -20,14 +20,14 @@
#include "min_allocator.h"
template <class S, class Pred>
-void test0(S s, Pred p, S expected, 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 test() {
auto is1 = [](auto v) { return v == 1; };
auto is2 = [](auto v) { return v == 2; };
auto is3 = [](auto v) { return v == 3; };
>From 42f2950a3143df5907a575323230e284e3cf3834 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 16:18:08 -0500
Subject: [PATCH 6/9] Test set.observers
---
.../std/containers/associative/set/set.observers/comp.pass.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp b/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
index 9aef8c7cce41b..dcea523540247 100644
--- a/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/set.observers/comp.pass.cpp
@@ -14,6 +14,8 @@
#include <set>
#include <cassert>
+#include "test_macros.h"
+
TEST_CONSTEXPR_CXX26 bool test() {
typedef std::set<int> set_type;
>From b30297eee8b6ed88b907c41663b9203003a3bac7 Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 17:48:30 -0500
Subject: [PATCH 7/9] hash correct version from main
---
libcxx/include/__functional/hash.h | 9 ---------
libcxx/test/support/poisoned_hash_helper.h | 10 +++-------
2 files changed, 3 insertions(+), 16 deletions(-)
diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h
index 83bbf1b5e26c3..f74f25fa6e84b 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -433,13 +433,10 @@ struct __hash_impl<long double> : __scalar_hash<long double> {
template <class _Tp>
struct hash : public __hash_impl<_Tp> {};
-#if _LIBCPP_STD_VER >= 17
-
template <>
struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {
_LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }
};
-#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Hash>
@@ -452,18 +449,12 @@ template <class _Key, class _Hash = hash<_Key> >
using __has_enabled_hash _LIBCPP_NODEBUG =
integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >;
-# if _LIBCPP_STD_VER >= 17
template <class _Type, class>
using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type;
template <class _Type, class... _Keys>
using __enable_hash_helper _LIBCPP_NODEBUG =
__enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >;
-# else
-template <class _Type, class...>
-using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
-# endif
-
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
diff --git a/libcxx/test/support/poisoned_hash_helper.h b/libcxx/test/support/poisoned_hash_helper.h
index 93b579d2dfde3..cd71cd70d6a84 100644
--- a/libcxx/test/support/poisoned_hash_helper.h
+++ b/libcxx/test/support/poisoned_hash_helper.h
@@ -123,13 +123,9 @@ struct Class {};
// Each header that declares the std::hash template provides enabled
// specializations of std::hash for std::nullptr_t and all cv-unqualified
// arithmetic, enumeration, and pointer types.
-#if TEST_STD_VER >= 17
-using MaybeNullptr = types::type_list<std::nullptr_t>;
-#else
-using MaybeNullptr = types::type_list<>;
-#endif
-using LibraryHashTypes = types::
- concatenate_t<types::arithmetic_types, types::type_list<Enum, EnumClass, void*, void const*, Class*>, MaybeNullptr>;
+using LibraryHashTypes =
+ types::concatenate_t<types::arithmetic_types,
+ types::type_list<Enum, EnumClass, void*, void const*, Class*, std::nullptr_t>>;
struct TestHashEnabled {
template <class T>
>From df77e29f261fd166ef1a56908df8519d941b59fb Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 17:57:58 -0500
Subject: [PATCH 8/9] saturation correct version from main
---
libcxx/include/__numeric/saturation_arithmetic.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libcxx/include/__numeric/saturation_arithmetic.h b/libcxx/include/__numeric/saturation_arithmetic.h
index 7a7410b5dea08..4491bab2b1479 100644
--- a/libcxx/include/__numeric/saturation_arithmetic.h
+++ b/libcxx/include/__numeric/saturation_arithmetic.h
@@ -121,27 +121,27 @@ _LIBCPP_HIDE_FROM_ABI constexpr _Rp __saturate_cast(_Tp __x) noexcept {
#if _LIBCPP_STD_VER >= 26
template <__signed_or_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp add_sat(_Tp __x, _Tp __y) noexcept {
return std::__add_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp sub_sat(_Tp __x, _Tp __y) noexcept {
return std::__sub_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp mul_sat(_Tp __x, _Tp __y) noexcept {
return std::__mul_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp div_sat(_Tp __x, _Tp __y) noexcept {
return std::__div_sat(__x, __y);
}
template <__signed_or_unsigned_integer _Rp, __signed_or_unsigned_integer _Tp>
-_LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Rp saturate_cast(_Tp __x) noexcept {
return std::__saturate_cast<_Rp>(__x);
}
>From 7ce7dcdba3724e6109ca2b925077771d7f2d79ca Mon Sep 17 00:00:00 2001
From: Vinay Deshmukh <vinay_deshmukh at outlook.com>
Date: Sun, 9 Nov 2025 21:10:14 -0500
Subject: [PATCH 9/9] Fix set/ final tests
---
libcxx/include/__node_handle | 4 +++-
.../containers/associative/set/contains.pass.cpp | 6 ++++--
.../associative/set/contains_transparent.pass.cpp | 15 ++++++++++-----
.../associative/set/count_transparent.pass.cpp | 10 +++++++---
.../containers/associative/set/emplace.pass.cpp | 5 +++--
.../associative/set/emplace_hint.pass.cpp | 5 +++--
.../set/equal_range_transparent.pass.cpp | 10 +++++++---
.../associative/set/erase_iter.pass.cpp | 4 ++--
.../associative/set/extract_iterator.pass.cpp | 4 ++--
.../associative/set/extract_key.pass.cpp | 4 ++--
...rt_and_emplace_allocator_requirements.pass.cpp | 15 ++++-----------
.../containers/associative/set/insert_cv.pass.cpp | 2 +-
.../associative/set/insert_iter_iter.pass.cpp | 8 ++------
.../associative/set/insert_node_type.pass.cpp | 13 +++++++------
.../set/insert_node_type_hint.pass.cpp | 9 +++++----
.../associative/set/insert_range.pass.cpp | 1 +
.../std/containers/associative/set/merge.pass.cpp | 13 +++++++------
.../test/std/containers/insert_range_maps_sets.h | 12 ++++++------
.../set_allocator_requirement_test_templates.h | 2 +-
19 files changed, 77 insertions(+), 65 deletions(-)
diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle
index 58be5b9d4ddd5..6d253cb4eaa98 100644
--- a/libcxx/include/__node_handle
+++ b/libcxx/include/__node_handle
@@ -172,7 +172,9 @@ template <class _NodeType, class _Derived>
struct __set_node_handle_specifics {
typedef typename _NodeType::__node_value_type value_type;
- _LIBCPP_HIDE_FROM_ABI value_type& value() const { return static_cast<_Derived const*>(this)->__ptr_->__get_value(); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_type& value() const {
+ return static_cast<_Derived const*>(this)->__ptr_->__get_value();
+ }
};
template <class _NodeType, class _Derived>
diff --git a/libcxx/test/std/containers/associative/set/contains.pass.cpp b/libcxx/test/std/containers/associative/set/contains.pass.cpp
index 20b1eeb839414..c147b01d73c10 100644
--- a/libcxx/test/std/containers/associative/set/contains.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/contains.pass.cpp
@@ -11,12 +11,14 @@
#include <cassert>
#include <set>
+#include "test_macros.h"
+
// <set>
// constexpr bool contains(const key_type& x) const; // constexpr since C++26
template <typename T, typename V, typename B, typename... Vals>
-void test(B bad, Vals... args) {
+TEST_CONSTEXPR_CXX26 void test(B bad, Vals... args) {
T set;
V vals[] = {args...};
@@ -39,7 +41,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
test<std::set<int>, int>(14, 10, 11, 12, 13);
test<std::set<char>, char>('e', 'a', 'b', 'c', 'd');
}
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
test<std::multiset<int>, int>(14, 10, 11, 12, 13);
test<std::multiset<char>, char>('e', 'a', 'b', 'c', 'd');
}
diff --git a/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
index acd03e649095f..0b7e032414425 100644
--- a/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/contains_transparent.pass.cpp
@@ -18,18 +18,22 @@
#include <set>
#include <utility>
+#include "test_macros.h"
+
struct Comp {
using is_transparent = void;
- bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const {
+ return lhs < rhs;
+ }
- bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
- bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
+ TEST_CONSTEXPR_CXX26 bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
};
template <typename Container>
-void test() {
+TEST_CONSTEXPR_CXX26 void test() {
Container s{{2, 1}, {1, 2}, {1, 3}, {1, 4}, {2, 2}};
assert(s.contains(1));
@@ -38,7 +42,8 @@ void test() {
TEST_CONSTEXPR_CXX26 bool test() {
test<std::set<std::pair<int, int>, Comp> >();
- test<std::multiset<std::pair<int, int>, Comp> >();
+ if (!TEST_IS_CONSTANT_EVALUATED)
+ test<std::multiset<std::pair<int, int>, Comp> >();
return true;
}
diff --git a/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
index 9147b38e5d336..a14f4efe8c48d 100644
--- a/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/count_transparent.pass.cpp
@@ -19,14 +19,18 @@
#include <set>
#include <utility>
+#include "test_macros.h"
+
struct Comp {
using is_transparent = void;
- bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const {
+ return lhs < rhs;
+ }
- bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
- bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
+ TEST_CONSTEXPR_CXX26 bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
};
TEST_CONSTEXPR_CXX26 bool test() {
diff --git a/libcxx/test/std/containers/associative/set/emplace.pass.cpp b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
index fecd9ef2fe7f9..6c93d99356c12 100644
--- a/libcxx/test/std/containers/associative/set/emplace.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
TEST_CONSTEXPR_CXX26 bool test() {
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
typedef std::set<DefaultOnly> M;
typedef std::pair<M::iterator, bool> R;
M m;
@@ -43,7 +43,8 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*m.begin() == DefaultOnly());
assert(DefaultOnly::count == 1);
}
- assert(DefaultOnly::count == 0);
+ if (!TEST_IS_CONSTANT_EVALUATED)
+ assert(DefaultOnly::count == 0);
{
typedef std::set<Emplaceable> M;
typedef std::pair<M::iterator, bool> R;
diff --git a/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
index 5c68000ffbab9..5282f4295ec8e 100644
--- a/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
@@ -24,7 +24,7 @@
#include "min_allocator.h"
TEST_CONSTEXPR_CXX26 bool test() {
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
typedef std::set<DefaultOnly> M;
typedef M::iterator R;
M m;
@@ -41,7 +41,8 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(*m.begin() == DefaultOnly());
assert(DefaultOnly::count == 1);
}
- assert(DefaultOnly::count == 0);
+ if (!TEST_IS_CONSTANT_EVALUATED)
+ assert(DefaultOnly::count == 0);
{
typedef std::set<Emplaceable> M;
typedef M::iterator R;
diff --git a/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
index 92c1c64be658c..9f2606412a5d2 100644
--- a/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/equal_range_transparent.pass.cpp
@@ -23,14 +23,18 @@
#include <set>
#include <utility>
+#include "test_macros.h"
+
struct Comp {
using is_transparent = void;
- bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const { return lhs < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, const std::pair<int, int>& rhs) const {
+ return lhs < rhs;
+ }
- bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
+ TEST_CONSTEXPR_CXX26 bool operator()(const std::pair<int, int>& lhs, int rhs) const { return lhs.first < rhs; }
- bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
+ TEST_CONSTEXPR_CXX26 bool operator()(int lhs, const std::pair<int, int>& rhs) const { return lhs < rhs.first; }
};
TEST_CONSTEXPR_CXX26 bool test() {
diff --git a/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
index 7682a81dc7407..952714a3720b0 100644
--- a/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
@@ -20,10 +20,10 @@
struct TemplateConstructor {
template <typename T>
- TemplateConstructor(const T&) {}
+ TEST_CONSTEXPR_CXX26 TemplateConstructor(const T&) {}
};
-bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
+TEST_CONSTEXPR_CXX26 bool operator<(const TemplateConstructor&, const TemplateConstructor&) { return false; }
TEST_CONSTEXPR_CXX26 bool test() {
{
diff --git a/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp b/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
index 1511b08079d03..59a83338da06f 100644
--- a/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/extract_iterator.pass.cpp
@@ -20,7 +20,7 @@
#include "Counter.h"
template <class Container>
-void test(Container& c) {
+TEST_CONSTEXPR_CXX26 void test(Container& c) {
std::size_t sz = c.size();
for (auto first = c.cbegin(); first != c.cend();) {
@@ -42,7 +42,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
test(m);
}
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
assert(Counter_base::gConstructed == 6);
test(m);
diff --git a/libcxx/test/std/containers/associative/set/extract_key.pass.cpp b/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
index 07f6d193179a8..432bfbdb1b8fb 100644
--- a/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/extract_key.pass.cpp
@@ -20,7 +20,7 @@
#include "Counter.h"
template <class Container, class KeyTypeIter>
-void test(Container& c, KeyTypeIter first, KeyTypeIter last) {
+TEST_CONSTEXPR_CXX26 void test(Container& c, KeyTypeIter first, KeyTypeIter last) {
std::size_t sz = c.size();
assert((std::size_t)std::distance(first, last) == sz);
@@ -48,7 +48,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
test(m, std::begin(keys), std::end(keys));
}
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
{
Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
diff --git a/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
index ace31eb66ea8d..4711473de4dad 100644
--- a/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp
@@ -10,9 +10,9 @@
// class set
-// constexpr insert(...) // constexpr since C++26
-// constexpr emplace(...) // constexpr since C++26
-// constexpr emplace_hint(...) // constexpr since C++26
+// insert(...)
+// emplace(...)
+// emplace_hint(...)
// UNSUPPORTED: c++03
@@ -21,17 +21,10 @@
#include "container_test_types.h"
#include "../../set_allocator_requirement_test_templates.h"
-TEST_CONSTEXPR_CXX26 bool test() {
+int main(int, char**) {
testSetInsert<TCT::set<> >();
testSetEmplace<TCT::set<> >();
testSetEmplaceHint<TCT::set<> >();
- 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/associative/set/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
index ef278224f0229..3dc33a80fe2ad 100644
--- a/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
@@ -19,7 +19,7 @@
#include "min_allocator.h"
template <class Container>
-void do_insert_cv_test() {
+TEST_CONSTEXPR_CXX26 void do_insert_cv_test() {
typedef Container M;
typedef std::pair<typename M::iterator, bool> R;
typedef typename M::value_type VT;
diff --git a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
index 6d6bd185afa04..ca0180af82897 100644
--- a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
@@ -21,7 +21,7 @@
#include "test_iterators.h"
template <class Iter, class Alloc>
-void test_alloc() {
+TEST_CONSTEXPR_CXX26 void test_alloc() {
{ // Check that an empty range works correctly
{ // Without elements in the container
using Map = std::set<int, std::less<int>, Alloc>;
@@ -178,13 +178,9 @@ void test_alloc() {
}
}
-void test() {
+TEST_CONSTEXPR_CXX26 bool test() {
test_alloc<cpp17_input_iterator<int*>, std::allocator<int> >();
test_alloc<cpp17_input_iterator<int*>, min_allocator<int> >();
-}
-
-TEST_CONSTEXPR_CXX26 bool test() {
- test();
return true;
}
diff --git a/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
index 935a90afedb2b..1512debd4e0bd 100644
--- a/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_node_type.pass.cpp
@@ -21,7 +21,7 @@
#include "min_allocator.h"
template <class Container, class T>
-void verify_insert_return_type(T&& t) {
+TEST_CONSTEXPR_CXX26 void verify_insert_return_type(T&& t) {
using verified_type = std::remove_cv_t<std::remove_reference_t<T>>;
static_assert(std::is_aggregate_v<verified_type>);
static_assert(std::is_same_v<verified_type, typename Container::insert_return_type>);
@@ -42,19 +42,20 @@ void verify_insert_return_type(T&& t) {
}
template <class Container>
-typename Container::node_type node_factory(typename Container::key_type const& key) {
- static Container c;
+TEST_CONSTEXPR_CXX26 typename Container::node_type node_factory(Container& c, typename Container::key_type const& key) {
auto p = c.insert(key);
assert(p.second);
return c.extract(p.first);
}
template <class Container>
-void test(Container& c) {
+TEST_CONSTEXPR_CXX26 void test(Container& c) {
auto* nf = &node_factory<Container>;
+ Container c2;
+
for (int i = 0; i != 10; ++i) {
- typename Container::node_type node = nf(i);
+ typename Container::node_type node = nf(c2, i);
assert(!node.empty());
typename Container::insert_return_type irt = c.insert(std::move(node));
assert(node.empty());
@@ -77,7 +78,7 @@ void test(Container& c) {
}
{ // Insert duplicate node.
- typename Container::node_type dupl = nf(0);
+ typename Container::node_type dupl = nf(c2, 0);
auto irt = c.insert(std::move(dupl));
assert(dupl.empty());
assert(!irt.inserted);
diff --git a/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp b/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
index f14263595ac6a..a1df9de53ae8a 100644
--- a/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
@@ -19,19 +19,20 @@
#include "min_allocator.h"
template <class Container>
-typename Container::node_type node_factory(typename Container::key_type const& key) {
- static Container c;
+TEST_CONSTEXPR_CXX26 typename Container::node_type node_factory(Container& c, typename Container::key_type const& key) {
auto p = c.insert(key);
assert(p.second);
return c.extract(p.first);
}
template <class Container>
-void test(Container& c) {
+TEST_CONSTEXPR_CXX26 void test(Container& c) {
auto* nf = &node_factory<Container>;
+ Container c2;
+
for (int i = 0; i != 10; ++i) {
- typename Container::node_type node = nf(i);
+ typename Container::node_type node = nf(c2, i);
assert(!node.empty());
std::size_t prev = c.size();
auto it = c.insert(c.end(), std::move(node));
diff --git a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
index 654d4d425774a..00cead676709a 100644
--- a/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/insert_range.pass.cpp
@@ -9,6 +9,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// Some fields in the test case variables are deliberately not explicitly initialized, this silences a warning on GCC.
// ADDITIONAL_COMPILE_FLAGS(gcc-style-warnings): -Wno-missing-field-initializers
+// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=2147483647
// <set>
diff --git a/libcxx/test/std/containers/associative/set/merge.pass.cpp b/libcxx/test/std/containers/associative/set/merge.pass.cpp
index 4c76c59ec5de5..bcaf13d4a7e1b 100644
--- a/libcxx/test/std/containers/associative/set/merge.pass.cpp
+++ b/libcxx/test/std/containers/associative/set/merge.pass.cpp
@@ -27,7 +27,7 @@
#include "Counter.h"
template <class Set>
-bool set_equal(const Set& set, Set other) {
+TEST_CONSTEXPR_CXX26 bool set_equal(const Set& set, Set other) {
return set == other;
}
@@ -55,8 +55,8 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(set_equal(dst, {1, 2, 3, 4, 5}));
}
-#ifndef TEST_HAS_NO_EXCEPTIONS
- {
+#if !defined(TEST_HAS_NO_EXCEPTIONS)
+ if (!TEST_IS_CONSTANT_EVALUATED) {
bool do_throw = false;
typedef std::set<Counter<int>, throw_comparator> set_type;
set_type src({1, 3, 5}, throw_comparator(do_throw));
@@ -75,13 +75,14 @@ TEST_CONSTEXPR_CXX26 bool test() {
assert(set_equal(dst, set_type({2, 4, 5}, throw_comparator(do_throw))));
}
#endif
- assert(Counter_base::gConstructed == 0);
+ if (!TEST_IS_CONSTANT_EVALUATED)
+ assert(Counter_base::gConstructed == 0);
struct comparator {
comparator() = default;
bool operator()(const Counter<int>& lhs, const Counter<int>& rhs) const { return lhs < rhs; }
};
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
typedef std::set<Counter<int>, std::less<Counter<int>>> first_set_type;
typedef std::set<Counter<int>, comparator> second_set_type;
typedef std::multiset<Counter<int>, comparator> third_set_type;
@@ -128,7 +129,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
first.merge(second);
first.merge(std::move(second));
}
- {
+ if (!TEST_IS_CONSTANT_EVALUATED) {
std::multiset<int> second;
first.merge(second);
first.merge(std::move(second));
diff --git a/libcxx/test/std/containers/insert_range_maps_sets.h b/libcxx/test/std/containers/insert_range_maps_sets.h
index 6e344d8ad3b0f..8563b7b43b934 100644
--- a/libcxx/test/std/containers/insert_range_maps_sets.h
+++ b/libcxx/test/std/containers/insert_range_maps_sets.h
@@ -200,7 +200,7 @@ TestCaseMapSet<std::pair<K, V>> constexpr NElementsContainer_RangeWithDuplicates
{16, 'D'}}};
template <class Container, class T, class Iter, class Sent>
-void test_map_set_insert_range(bool allow_duplicates = false) {
+TEST_CONSTEXPR_CXX26 void test_map_set_insert_range(bool allow_duplicates = false) {
auto test = [&](const TestCaseMapSet<T>& test_case, bool check_multi = false) {
Container c(test_case.initial.begin(), test_case.initial.end());
auto in = wrap_input<Iter, Sent>(test_case.input);
@@ -250,7 +250,7 @@ void test_map_set_insert_range(bool allow_duplicates = false) {
// Move-only types.
template <template <class...> class Container>
-void test_set_insert_range_move_only() {
+TEST_CONSTEXPR_CXX26 void test_set_insert_range_move_only() {
MoveOnly input[5];
std::ranges::subrange in(std::move_iterator{input}, std::move_iterator{input + 5});
@@ -271,8 +271,8 @@ void test_map_insert_range_move_only() {
// Exception safety.
template <template <class...> class Container>
-void test_set_insert_range_exception_safety_throwing_copy() {
-#if !defined(TEST_HAS_NO_EXCEPTIONS)
+TEST_CONSTEXPR_CXX26 void test_set_insert_range_exception_safety_throwing_copy() {
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(TEST_IS_CONSTANT_EVALUATED)
using T = ThrowingCopy<3>;
T::reset();
T in[5] = {{1}, {2}, {3}, {4}, {5}};
@@ -313,8 +313,8 @@ void test_map_insert_range_exception_safety_throwing_copy() {
}
template <template <class...> class Container, class T>
-void test_assoc_set_insert_range_exception_safety_throwing_allocator() {
-#if !defined(TEST_HAS_NO_EXCEPTIONS)
+TEST_CONSTEXPR_CXX26 void test_assoc_set_insert_range_exception_safety_throwing_allocator() {
+#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(TEST_IS_CONSTANT_EVALUATED)
T in[] = {1, 2};
try {
diff --git a/libcxx/test/std/containers/set_allocator_requirement_test_templates.h b/libcxx/test/std/containers/set_allocator_requirement_test_templates.h
index 10552a5b9ee21..f6bda0eddfbb4 100644
--- a/libcxx/test/std/containers/set_allocator_requirement_test_templates.h
+++ b/libcxx/test/std/containers/set_allocator_requirement_test_templates.h
@@ -27,7 +27,7 @@
#include "container_test_types.h"
template <class Container>
-void testSetInsert() {
+TEST_CONSTEXPR_CXX26 void testSetInsert() {
typedef typename Container::value_type ValueTp;
ConstructController* cc = getConstructController();
cc->reset();
More information about the libcxx-commits
mailing list