Skip to content

[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

Open
wants to merge 187 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 166 commits
Commits
Show all changes
187 commits
Select commit Hold shift + click to select a range
83583bb
Apply initial _LIBCPP_CONSTEXPR_SINCE_CXX26
vinay-deshmukh Apr 4, 2025
6560dd5
Add feature test macro
vinay-deshmukh Apr 4, 2025
ce1a62f
one test to start with
vinay-deshmukh Apr 4, 2025
a72b619
start seeing constexpr failures for at.pass.cpp
vinay-deshmukh Apr 5, 2025
c04441e
member call on object outside its lifetime is not allowed in a const…
vinay-deshmukh Apr 5, 2025
ec9317e
Move past member call on object past it's lifetime
vinay-deshmukh Apr 6, 2025
cec33fb
Add ctor to initialize __value_type and __tree_node_base, and the obj…
vinay-deshmukh Apr 6, 2025
0574be6
construction works, at() fails due to throw_out_of_range
vinay-deshmukh Apr 6, 2025
ed995a2
can't intentionally throw in constexpr
vinay-deshmukh Apr 6, 2025
e941811
note: cast from 'void *' is not allowed in a constant expression beca…
vinay-deshmukh Apr 6, 2025
def8261
note: cast from 'void *' is not allowed in a constant expression beca…
vinay-deshmukh Apr 6, 2025
76fcef6
ignore min_allocator tests for now
vinay-deshmukh Apr 6, 2025
9ea718f
at.pass.cpp works in cpp26 for some reason
vinay-deshmukh Apr 7, 2025
a38112b
empty.verify.cpp passes
vinay-deshmukh Apr 7, 2025
b9d17a9
index_key_.pass.cpp constexpr fixed, but other failure
vinay-deshmukh Apr 7, 2025
7cbc6c8
index_rv_key.pass.cpp constexpr fixed, but other failure
vinay-deshmukh Apr 7, 2025
e8b0649
fix index_tuple.pass.cpp
vinay-deshmukh Apr 7, 2025
5c51105
fix: iterator.pass.cpp
vinay-deshmukh Apr 7, 2025
ed34a53
fix max_size.pass.cpp
vinay-deshmukh Apr 7, 2025
1d3b9ef
size.pass.cpp
vinay-deshmukh Apr 7, 2025
e124b63
alloc.pass.cpp
vinay-deshmukh Apr 7, 2025
938989c
blocked on assign_initializer_list
vinay-deshmukh Apr 9, 2025
7d73d59
compare.pass.cpp
vinay-deshmukh Apr 9, 2025
30ec57c
Modify all tests to have TEST_CONSTEXPR_CXX26 and without
vinay-deshmukh Apr 9, 2025
21c442c
passing at: copy_assign.addressof.compile.pass.cpp
vinay-deshmukh Apr 9, 2025
1e86d9c
failing at copy_assign.pass.cpp only in constexpr
vinay-deshmukh Apr 9, 2025
85e1cfc
pass deduct.pass.cpp
vinay-deshmukh Apr 9, 2025
6ebe12c
fix map.cons/from_range.pass.cpp
vinay-deshmukh Apr 9, 2025
ff72cf9
fail at map.cons/move_alloc.pass.cpp
vinay-deshmukh Apr 9, 2025
76c02b7
fail at map.cons/move_assign.pass.cpp
vinay-deshmukh Apr 9, 2025
2a7d238
fix map.cons/move_noexcept.pass.cpp
vinay-deshmukh Apr 9, 2025
f188a7b
pass map.erasure/erase_if.pass.cpp
vinay-deshmukh Apr 9, 2025
6a08bff
error: call to deleted constructor at map.modifiers/emplace.pass.cpp
vinay-deshmukh Apr 9, 2025
2b47aba
pass map.modifiers/erase_iter.pass.cpp
vinay-deshmukh Apr 9, 2025
e045092
pass map.modifiers/extract_iterator.pass.cpp
vinay-deshmukh Apr 9, 2025
d61d023
TODO: node-handle tests
vinay-deshmukh Apr 9, 2025
5b564ff
pass map.modifiers/extract_key.pass.cpp
vinay-deshmukh Apr 9, 2025
d17a5f4
pass map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp
vinay-deshmukh Apr 9, 2025
9e3fff0
pass map.modifiers/insert_cv.pass.cpp
vinay-deshmukh Apr 9, 2025
662d172
pass map.modifiers/insert_iter_cv.pass.cpp
vinay-deshmukh Apr 9, 2025
3c39ba7
pass map.modifiers/insert_iter_rv.pass.cpp
vinay-deshmukh Apr 9, 2025
a462c8e
pass map.modifiers/insert_node_type.pass
vinay-deshmukh Apr 9, 2025
d57d651
pass map.modifiers/insert_node_type_hint.pass.cpp
vinay-deshmukh Apr 9, 2025
8c94f4d
pass map.modifiers/insert_or_assign.pass.cpp
vinay-deshmukh Apr 9, 2025
dc5fbee
pass map.modifiers/insert_rv.pass.cpp
vinay-deshmukh Apr 9, 2025
674854d
pass map.modifiers/try.emplace.pass.cpp, fix typos
vinay-deshmukh Apr 9, 2025
a00a45a
pass map.nonmember/compare.three_way.pass.cpp
vinay-deshmukh Apr 9, 2025
3728788
pass map.nonmember/op_compare.pass.cpp
vinay-deshmukh Apr 9, 2025
490645c
pass map.observers/key_comp.pass.cpp
vinay-deshmukh Apr 9, 2025
f136d58
pass map.observers/value_comp.pass.cpp
vinay-deshmukh Apr 9, 2025
bef3a7f
pass map.ops/contains.pass.cpp
vinay-deshmukh Apr 9, 2025
784b1c9
pass map.ops/contains_transparent.pass.cpp
vinay-deshmukh Apr 9, 2025
2b9085b
pass map.ops/count.pass.cpp
vinay-deshmukh Apr 9, 2025
995c23a
pass map.ops/count_transparent.pass.cpp
vinay-deshmukh Apr 9, 2025
aba79eb
pass map.ops/equal_range_transparent.pass.cpp
vinay-deshmukh Apr 9, 2025
70f2163
pass map.special/member_swap.pass.cpp
vinay-deshmukh Apr 10, 2025
f20cfeb
pass map.value_compare/invoke.pass.cpp
vinay-deshmukh Apr 10, 2025
381bd9b
pass map.value_compare/types.pass.cpp
vinay-deshmukh Apr 10, 2025
b3218a7
cleanup
vinay-deshmukh Apr 10, 2025
7cfa07f
Pass compare.pass.cpp
vinay-deshmukh Apr 10, 2025
7930edd
pass incomplete_type.pass.cpp
vinay-deshmukh Apr 10, 2025
2ff98ea
error: call to deleted constructor of '__node_value_type' (aka 'std::…
vinay-deshmukh Apr 10, 2025
27f2bfe
clang-format
vinay-deshmukh Apr 10, 2025
10f536f
Generate macro version correctly
vinay-deshmukh Apr 10, 2025
1270c3e
fix unrelated CI failures
vinay-deshmukh Apr 10, 2025
97b00cd
pass map.modifiers/emplace.pass.cpp
vinay-deshmukh Apr 10, 2025
900d449
pass map.modifiers/emplace_hint.pass.cpp
vinay-deshmukh Apr 10, 2025
71b4ffb
WIP:Merge remote-tracking branch 'upstream/main' into vinay-issue-128…
vinay-deshmukh Jun 8, 2025
f470158
at.pass.cpp passes again
vinay-deshmukh Jun 8, 2025
687ca5f
iterator.pass.cpp passes
vinay-deshmukh Jun 8, 2025
eb3c0f8
move_assign.pass.cpp constexpr fixed
vinay-deshmukh Jun 8, 2025
b5577a6
move_alloc.pass.cpp constexpr fixed, other remains
vinay-deshmukh Jun 8, 2025
dda93ff
copy_assign.pass.cpp constexpr fixed, other remains
vinay-deshmukh Jun 8, 2025
ab52bea
erase_iter.pass.cpp
vinay-deshmukh Jun 8, 2025
f9a4e70
fix typo
vinay-deshmukh Jun 8, 2025
37110f1
map.ops pass
vinay-deshmukh Jun 8, 2025
fedf39b
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jun 8, 2025
f3b5970
Partially fix assign_initializer_list.pass.cpp
vinay-deshmukh Jun 8, 2025
1d9e310
Fix assign_initializer_list.pass.cpp
vinay-deshmukh Jun 8, 2025
d8095a7
fix placement new to use std::addressof
vinay-deshmukh Jun 8, 2025
01d8633
fix copy_assign.pass.cpp
vinay-deshmukh Jun 8, 2025
e2f3b8f
move alloc failure location
vinay-deshmukh Jun 8, 2025
0cce96e
git-clang-format upstream/main
vinay-deshmukh Jun 9, 2025
2b8603c
featuer test generation
vinay-deshmukh Jun 9, 2025
fa77a07
<__type_traits/is_constant_evaluated.h>
vinay-deshmukh Jun 15, 2025
62f137a
__node_value_type
vinay-deshmukh Jun 15, 2025
4cb5709
Use __libcpp_is_constant_evaluated, still at 7 failures
vinay-deshmukh Jun 19, 2025
8fbff81
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jun 19, 2025
8b84759
fix feature gen?
vinay-deshmukh Jun 19, 2025
c1b827d
feature macros
vinay-deshmukh Jun 19, 2025
664b3c6
? lang support
vinay-deshmukh Jun 19, 2025
92482b7
cf
vinay-deshmukh Jun 19, 2025
e24ff11
restore pair to main
vinay-deshmukh Jun 19, 2025
a492d0d
back at 7 failures due to min_allocator.h
vinay-deshmukh Jun 19, 2025
a205de2
cf?
vinay-deshmukh Jun 19, 2025
adc5f50
insert_range.pass.cpp, empty passes, stuck at next
vinay-deshmukh Jun 19, 2025
47943d9
min_allocator to main
vinay-deshmukh Jun 21, 2025
db54c2c
tree
vinay-deshmukh Jun 21, 2025
1e3bd1c
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jun 21, 2025
75e3cd1
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jul 4, 2025
bd0d751
clang format
vinay-deshmukh Jul 4, 2025
b73e365
fix CI?
vinay-deshmukh Jul 4, 2025
b9d4d95
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jul 6, 2025
254b686
try CI fix?
vinay-deshmukh Jul 6, 2025
e48e585
readability-identifier-naming
vinay-deshmukh Jul 6, 2025
281e462
libcpp-hide-from-abi
vinay-deshmukh Jul 6, 2025
812c167
cf
vinay-deshmukh Jul 6, 2025
e631266
_Args not Args
vinay-deshmukh Jul 6, 2025
3a24e31
map?
vinay-deshmukh Jul 6, 2025
1744e8a
generic-cxx03
vinay-deshmukh Jul 6, 2025
a31f09b
libcpp-hide-from-abi
vinay-deshmukh Jul 6, 2025
8c401a6
cxx03
vinay-deshmukh Jul 6, 2025
7c72e0e
tmp
vinay-deshmukh Jul 6, 2025
54107af
WIP???
vinay-deshmukh Jul 12, 2025
a34f7af
Merge commit 'afcf76bda18c09cffd88cb562768385f97ebf894' into vinay-is…
vinay-deshmukh Jul 12, 2025
7dfa7c1
constexpr test ID*
vinay-deshmukh Jul 13, 2025
1549261
at.pass.cpp works
vinay-deshmukh Jul 29, 2025
17f8361
empty.pass.cpp
vinay-deshmukh Jul 29, 2025
e9bdbb7
index_key.pass.cpp -> static_assert
vinay-deshmukh Jul 29, 2025
c695518
iterator.pass.cpp
vinay-deshmukh Jul 29, 2025
0790081
size.pass.cpp
vinay-deshmukh Jul 29, 2025
16828a5
map.cons/assign_initializer_list.pass.cpp
vinay-deshmukh Jul 29, 2025
0dbe3d5
map.modifiers/emplace.pass.cpp
vinay-deshmukh Jul 29, 2025
e2938a5
map.modifiers/emplace_hint.pass.cpp
vinay-deshmukh Jul 29, 2025
ce082a3
map.modifiers/erase_key.pass.cpp
vinay-deshmukh Jul 29, 2025
64b93db
map.ops/count.pass.cpp
vinay-deshmukh Jul 29, 2025
bed849d
map.ops/equal_range.pass.cpp
vinay-deshmukh Jul 29, 2025
be3ac37
map.ops/find.pass.cpp
vinay-deshmukh Jul 29, 2025
f5a26ab
map.ops/upper_bound.pass.cpp
vinay-deshmukh Jul 29, 2025
07034d1
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Jul 29, 2025
e28df17
clang-format
vinay-deshmukh Jul 29, 2025
72912ac
fix error
vinay-deshmukh Aug 2, 2025
9356bb2
value_comp bad merge
vinay-deshmukh Aug 2, 2025
2a1d335
_root cannot be redeclared
vinay-deshmukh Aug 2, 2025
33fea96
remove base and cast
vinay-deshmukh Aug 2, 2025
0f3d0f1
copy_assign.pass.cpp
vinay-deshmukh Aug 3, 2025
c2f8451
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Aug 3, 2025
cca780a
fails largely because of constexpr limit, because for Container<int,…
vinay-deshmukh Aug 4, 2025
f1fabdc
use __node_traits::construct over placement new, copy_assing copy_all…
vinay-deshmukh Aug 5, 2025
d1de5b1
cf
vinay-deshmukh Aug 5, 2025
51cb5e2
note for failure
vinay-deshmukh Aug 5, 2025
446a15a
TODO
vinay-deshmukh Aug 7, 2025
f95216d
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Aug 9, 2025
d08023d
add constexpr cpp26
vinay-deshmukh Aug 9, 2025
d2a453a
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Aug 9, 2025
1d9a7e9
mistake
vinay-deshmukh Aug 9, 2025
61cc3cb
6 failures
vinay-deshmukh Aug 9, 2025
4b6bd5f
something
vinay-deshmukh Aug 9, 2025
a563260
clean
vinay-deshmukh Aug 9, 2025
325c9b7
clean more
vinay-deshmukh Aug 9, 2025
a5d575d
fix same_as allocate issues in index_rv_key
vinay-deshmukh Aug 10, 2025
1c46326
failures at move_alloc and move_assign
vinay-deshmukh Aug 10, 2025
f636597
allocator for copy_assign
vinay-deshmukh Aug 10, 2025
e57be9e
index_rv_key at it again
vinay-deshmukh Aug 10, 2025
d96f38b
haxxx
vinay-deshmukh Aug 10, 2025
ca06b8a
Temporary solution for UB & restriction
vinay-deshmukh Aug 10, 2025
ef90a64
copy_assign.pass.cpp
vinay-deshmukh Aug 10, 2025
9f27c4f
Finally only 2 tests fail
vinay-deshmukh Aug 10, 2025
36c1cc9
insert_key.pass.cpp
vinay-deshmukh Aug 10, 2025
8cafae7
Move_alloc.pass.cpp fails
vinay-deshmukh Aug 10, 2025
d72cf89
add docs
vinay-deshmukh Aug 10, 2025
a6c74cf
move_alloc and move_assign, fail in __insert_unique_from_orphaned_nod…
vinay-deshmukh Aug 10, 2025
8da6b53
kind of fixed it, almost
vinay-deshmukh Aug 10, 2025
c4a3034
Fix for move_assign
vinay-deshmukh Aug 11, 2025
77a9d5d
almost a fix for move_assign.pass.cpp
vinay-deshmukh Aug 11, 2025
27604a5
insert_range_maps_sets.h, needs a lot of constexpr depth
vinay-deshmukh Aug 11, 2025
d8d6278
add why sfinae
vinay-deshmukh Aug 11, 2025
187b86f
insert_and_emplace_allocator_requirements.pass.cpp passes
vinay-deshmukh Aug 11, 2025
b3deeb1
Merge remote-tracking branch 'upstream/main' into vinay-issue-128660-…
vinay-deshmukh Aug 11, 2025
2143eb5
use the typedef
vinay-deshmukh Aug 11, 2025
209f88d
remove concepts, collapse unnecessary sfinae
vinay-deshmukh Aug 11, 2025
a7235cb
some docs
vinay-deshmukh Aug 11, 2025
ee0a6b5
breaks correctly
vinay-deshmukh Aug 12, 2025
c8e907f
still correct failures with cleanup
vinay-deshmukh Aug 12, 2025
bfea79f
more cleans
vinay-deshmukh Aug 12, 2025
03a6a4a
more clean
vinay-deshmukh Aug 12, 2025
4fbb472
PR review comment
vinay-deshmukh Aug 12, 2025
b3e9926
include __memory/construct_at
vinay-deshmukh Aug 12, 2025
efd9f96
`Assertion `getConstructController()->isInAllocatorConstruct()' faile…
vinay-deshmukh Aug 12, 2025
ae13527
one clean
vinay-deshmukh Aug 12, 2025
ebfc34d
cleanup for libcxx/test/support/container_test_types.h
vinay-deshmukh Aug 12, 2025
4133867
clean back
vinay-deshmukh Aug 12, 2025
78fc8ca
clang-format
vinay-deshmukh Aug 12, 2025
0aa760e
adjust constexpr steps arg
vinay-deshmukh Aug 12, 2025
2edf9ac
clean
vinay-deshmukh Aug 12, 2025
7760d51
Redundant check
vinay-deshmukh Aug 12, 2025
06e38db
Add ReleaseNotes
vinay-deshmukh Aug 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand Down
3 changes: 2 additions & 1 deletion libcxx/include/__iterator/erase_if_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__memory/pointer_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
27 changes: 15 additions & 12 deletions libcxx/include/__node_handle
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -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_,
Expand All @@ -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_);
Expand All @@ -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>
Expand All @@ -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);
}
Expand Down
Loading
Loading