-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[libc++] Make <map>
std::map
constexpr as part of P3372R3
#134330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[libc++] Make <map>
std::map
constexpr as part of P3372R3
#134330
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
181a08d
to
6560dd5
Compare
…ect of unique_ptr
…use the pointed object type 'std::__tree_node<std::__value_type<int, double>, min_pointer<void>>' is not similar to the target type 'std::__tree_node_base<min_pointer<void>>'
…use the pointed object type 'std::__tree_node<std::__value_type<int, double>, min_pointer<void>>' is not similar to the target type 'std::__tree_node_base<min_pointer<void>>
46d0bb9
to
9ea718f
Compare
<map>
std::map
constexpr as part of P3372R3
…d.`Revert "PR review comment" This reverts commit 4fbb472. Fails with: ``` # .---command stderr------------ # | t.tmp.exe: /home/runner/_work/llvm-project/llvm-project/libcxx/test/support/container_test_types.h:399: CopyInsertable<1>::CopyInsertable(const CopyInsertable<Dummy> &) [Dummy = 1]: Assertion `getConstructController()->isInAllocatorConstruct()' failed. # `----------------------------- # error: command failed with exit status: 250 ```
990228b
to
efd9f96
Compare
Not sure what this failure is in gcc-15 tests:
AIX 32 fails with the following and basically the whole test suite(not sure if it has the up to date compiler) AIX is using Clang 19, so about a year old and that may be the cause of this failure:
|
@llvm/pr-subscribers-libcxx Author: Vinay Deshmukh (vinay-deshmukh) ChangesFixes #128660 Summary:
Patch is 294.88 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/134330.diff 91 Files Affected:
diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst
index a36848ebd24b4..07ec543c008ce 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -428,6 +428,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_list`` ``202502L``
---------------------------------------------------------- -----------------
+ ``__cpp_lib_constexpr_map`` ``202502L``
+ ---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_new`` ``202406L``
---------------------------------------------------------- -----------------
``__cpp_lib_constexpr_queue`` ``202502L``
diff --git a/libcxx/docs/ReleaseNotes/22.rst b/libcxx/docs/ReleaseNotes/22.rst
index 8b8dce5083149..41239be9c9ba8 100644
--- a/libcxx/docs/ReleaseNotes/22.rst
+++ b/libcxx/docs/ReleaseNotes/22.rst
@@ -45,6 +45,7 @@ Improvements and New Features
- The performance of ``map::map(const map&)`` has been improved up to 2.3x
- The performance of ``map::operator=(const map&)`` has been improved by up to 11x
+- P3372R3: ``constexpr map``(`Github <https://github.com/llvm/llvm-project/issues/128660>`__) (The paper is partially implemented. ``constexpr map`` is implemented in this release)
Deprecations and Removals
-------------------------
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/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h
index 8c7f8dff1b76b..62fcd93263b02 100644
--- a/libcxx/include/__memory/pointer_traits.h
+++ b/libcxx/include/__memory/pointer_traits.h
@@ -255,7 +255,7 @@ concept __resettable_smart_pointer_with_args = requires(_Smart __s, _Pointer __p
// This function ensures safe conversions between fancy pointers at compile-time, where we avoid casts from/to
// `__void_pointer` by obtaining the underlying raw pointer from the fancy pointer using `std::to_address`,
// then dereferencing it to retrieve the pointed-to object, and finally constructing the target fancy pointer
-// to that object using the `std::pointer_traits<>::pinter_to` function.
+// to that object using the `std::pointer_traits<>::pointer_to` function.
template <class _PtrTo, class _PtrFrom>
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _PtrTo __static_fancy_pointer_cast(const _PtrFrom& __p) {
using __ptr_traits = pointer_traits<_PtrTo>;
diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle
index b20b0c73a0518..6ce2e1b7d459c 100644
--- a/libcxx/include/__node_handle
+++ b/libcxx/include/__node_handle
@@ -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,8 @@ 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;
+ // https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2025/p3372r3.html#node-handle-key
+ // https://cplusplus.github.io/CWG/issues/2514.html
_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/__tree b/libcxx/include/__tree
index 6dadd0915c984..e3499f3a4769c 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -20,6 +20,7 @@
#include <__memory/addressof.h>
#include <__memory/allocator_traits.h>
#include <__memory/compressed_pair.h>
+#include <__memory/construct_at.h>
#include <__memory/pointer_traits.h>
#include <__memory/swap_allocator.h>
#include <__memory/unique_ptr.h>
@@ -27,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>
@@ -83,7 +86,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_;
}
@@ -140,7 +143,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_;
@@ -149,7 +152,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_;
@@ -158,7 +161,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_);
@@ -168,10 +171,10 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT {
}
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_);
@@ -180,11 +183,11 @@ inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEP
// 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();
@@ -192,7 +195,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) {
@@ -211,7 +214,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_;
@@ -230,7 +233,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_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI 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_;
@@ -254,7 +257,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;
@@ -310,7 +314,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");
@@ -525,7 +529,7 @@ public:
typedef _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_() {}
};
template <class _VoidPtr>
@@ -539,11 +543,16 @@ 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);
+ }
- ~__tree_node_base() = delete;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __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;
};
@@ -553,10 +562,16 @@ class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
public:
using __node_value_type _LIBCPP_NODEBUG = __get_node_value_type_t<_Tp>;
- __node_value_type __value_;
+ union {
+ __node_value_type __value_;
+ };
_LIBCPP_HIDE_FROM_ABI __node_value_type& __get_value() { return __value_; }
+ template <class _Alloc, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_node(_Alloc& __na, _Args&&... __args) {
+ allocator_traits<_Alloc>::construct(__na, std::addressof(__value_), std::forward<_Args>(__args)...);
+ }
~__tree_node() = delete;
__tree_node(__tree_node const&) = delete;
__tree_node& operator=(__tree_node const&) = delete;
@@ -576,14 +591,15 @@ private:
public:
bool __value_constructed;
- _LIBCPP_HIDE_FROM_ABI __tree_node_destructor(const __tree_node_destructor&) = default;
- __tree_node_destructor& operator=(const __tree_node_destructor&) = delete;
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node_destructor(const __tree_node_destructor&) = default;
+ _LIBCPP_CONSTEXPR_SINCE_CXX26 __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->__value_));
if (__p)
@@ -619,42 +635,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()->__value_; }
- _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits<pointer>::pointer_to(__get_np()->__value_); }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __get_np()->__value_; }
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const {
+ return pointer_traits<pointer>::pointer_to(__get_np()->__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!=...
[truncated]
|
…P3372-constexpr-map
Fixes #128660
Summary:
Apply
_LIBCPP_CONSTEXPR_SINCE_CXX26
tomap
,__tree
andnode-handle
map.modifiers/try.emplace.pass.cpp
: Start using the previously unusedmv3
. (Should this be a separate patch?)Has a TODO for
multimap
a.
libcxx/test/std/containers/associative/map/map.ops/contains.pass.cpp
b.
libcxx/test/std/containers/associative/map/map.ops/contains_transparent.pass.cpp
TODO: for
multimap
and others:a.
libcxx/test/std/containers/container.node/node_handle.pass.cpp
Fix typo in
libcxx/include/__memory/pointer_traits.h
pair<const MoveOnly, ...>
a.
move_assign.pass.cpp
b.
move_alloc.pass.cpp
c. Fails to compile if
static_assert(test());
is called in the test filed. Has a
// FIXME
with commented codeBased on this comment, I tried replacing:
a.
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
b. with
c.
std::__construct_at(std::addressof(__h->__value_), std::forward<_Args>(__args)...);
d. Fails with: