Skip to content

Commit 938989c

Browse files
blocked on assign_initializer_list
1 parent e124b63 commit 938989c

File tree

4 files changed

+41
-21
lines changed

4 files changed

+41
-21
lines changed

libcxx/include/__tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_left_rotate(_Nod
245245
// Effects: Makes __x->__left_ the subtree root with __x as its right child
246246
// while preserving in-order order.
247247
template <class _NodePtr>
248-
_LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
248+
_LIBCPP_CONSTEXPR_SINCE_CXX26 _LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT {
249249
_LIBCPP_ASSERT_INTERNAL(__x != nullptr, "node shouldn't be null");
250250
_LIBCPP_ASSERT_INTERNAL(__x->__left_ != nullptr, "node should have a left child");
251251
_NodePtr __y = __x->__left_;
@@ -1147,7 +1147,7 @@ public:
11471147
return __emplace_hint_multi(__p, std::forward<_Vp>(__v));
11481148
}
11491149

1150-
_LIBCPP_HIDE_FROM_ABI pair<iterator, bool>
1150+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair<iterator, bool>
11511151
__node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
11521152

11531153
_LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd);
@@ -1289,22 +1289,22 @@ private:
12891289
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
12901290

12911291
struct _DetachedTreeCache {
1292-
_LIBCPP_HIDE_FROM_ABI explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT
1292+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit _DetachedTreeCache(__tree* __t) _NOEXCEPT
12931293
: __t_(__t),
12941294
__cache_root_(__detach_from_tree(__t)) {
12951295
__advance();
12961296
}
12971297

1298-
_LIBCPP_HIDE_FROM_ABI __node_pointer __get() const _NOEXCEPT { return __cache_elem_; }
1298+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get() const _NOEXCEPT { return __cache_elem_; }
12991299

1300-
_LIBCPP_HIDE_FROM_ABI void __advance() _NOEXCEPT {
1300+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __advance() _NOEXCEPT {
13011301
__cache_elem_ = __cache_root_;
13021302
if (__cache_root_) {
13031303
__cache_root_ = __detach_next(__cache_root_);
13041304
}
13051305
}
13061306

1307-
_LIBCPP_HIDE_FROM_ABI ~_DetachedTreeCache() {
1307+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~_DetachedTreeCache() {
13081308
__t_->destroy(__cache_elem_);
13091309
if (__cache_root_) {
13101310
while (__cache_root_->__parent_ != nullptr)
@@ -1317,8 +1317,8 @@ private:
13171317
_DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete;
13181318

13191319
private:
1320-
_LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT;
1321-
_LIBCPP_HIDE_FROM_ABI static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
1320+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __node_pointer __detach_from_tree(__tree* __t) _NOEXCEPT;
1321+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
13221322

13231323
__tree* __t_;
13241324
__node_pointer __cache_root_;
@@ -1347,7 +1347,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const va
13471347

13481348
// Precondition: size() != 0
13491349
template <class _Tp, class _Compare, class _Allocator>
1350-
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
1350+
_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
13511351
__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree* __t) _NOEXCEPT {
13521352
__node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node());
13531353
__t->__begin_node() = __t->__end_node();
@@ -1367,7 +1367,7 @@ __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree
13671367
// __cache->right_ == nullptr
13681368
// This is no longer a red-black tree
13691369
template <class _Tp, class _Compare, class _Allocator>
1370-
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
1370+
_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
13711371
__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT {
13721372
if (__cache->__parent_ == nullptr)
13731373
return nullptr;
@@ -1945,7 +1945,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_hint_
19451945
}
19461946

19471947
template <class _Tp, class _Compare, class _Allocator>
1948-
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
1948+
_LIBCPP_CONSTEXPR_SINCE_CXX26 pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
19491949
__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd) {
19501950
__parent_pointer __parent;
19511951
__node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v));

libcxx/include/__utility/pair.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include <__utility/forward.h>
4040
#include <__utility/move.h>
4141
#include <__utility/piecewise_construct.h>
42+
#include <type_traits>
4243

4344
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4445
# pragma GCC system_header
@@ -244,6 +245,7 @@ struct _LIBCPP_TEMPLATE_VIS pair
244245
__enable_if_t<is_assignable<first_type&, _U1 const&>::value && is_assignable<second_type&, _U2 const&>::value,
245246
int> = 0>
246247
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) {
248+
// static_assert(std::is_same_v<decltype(first), decltype(__p.first)>);
247249
first = __p.first;
248250
second = __p.second;
249251
return *this;

libcxx/include/map

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ public:
802802
return std::addressof(__v.__cc_);
803803
}
804804

805-
_LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() {
805+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __nc_ref_pair_type __ref() {
806806
value_type& __v = __get_value();
807807
return __nc_ref_pair_type(const_cast<key_type&>(__v.first), __v.second);
808808
}
@@ -823,8 +823,26 @@ public:
823823
}
824824

825825
template <class _ValueTp, __enable_if_t<__is_same_uncvref<_ValueTp, value_type>::value, int> = 0>
826-
_LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) {
826+
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type& operator=(_ValueTp&& __v) {
827+
// static_assert(false && std::is_same_v<_ValueTp, value_type> && !std::is_same_v<_ValueTp, _ValueTp>
828+
// ,
829+
// "fail");
830+
// static_assert(std::is_same_v<decltype(__ref()), _ValueTp>, "fail");
831+
// static_assert(std::is_same_v<decltype(__ref()), decltype(__v.first)>, "fail");
832+
833+
// note: modification of object of const-qualified type 'const int' is not allowed in a constant expression
834+
// raised by: libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
827835
__ref() = std::forward<_ValueTp>(__v);
836+
// only shows up at compile time for C++26, not runtime, for C++23
837+
838+
// make a copy right now to get past above error
839+
// __ref() = _ValueTp{__v};
840+
841+
// value_type& __this_v = __get_value();
842+
// const_cast<key_type&>(__this_v.first) = __v.first;
843+
// disabled for now, because of above error,
844+
// __this_v.first = std::move(__v.first);
845+
// __this_v.second = __v.second;
828846
return *this;
829847
}
830848

libcxx/test/std/containers/test_compare.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
template <class T>
1313
struct test_equal_to {
1414
int data_;
15-
explicit test_equal_to() : data_(0) {}
16-
explicit test_equal_to(int data) : data_(data) {}
17-
bool operator()(const T& a, const T& b) const { return a == b; }
18-
friend bool operator==(const test_equal_to& a, const test_equal_to& b) { return a.data_ == b.data_; }
15+
TEST_CONSTEXPR_CXX26 explicit test_equal_to() : data_(0) {}
16+
TEST_CONSTEXPR_CXX26 explicit test_equal_to(int data) : data_(data) {}
17+
TEST_CONSTEXPR_CXX26 bool operator()(const T& a, const T& b) const { return a == b; }
18+
TEST_CONSTEXPR_CXX26 friend bool operator==(const test_equal_to& a, const test_equal_to& b) { return a.data_ == b.data_; }
1919
};
2020

2121
template <class T>
2222
struct test_less {
2323
int data_;
24-
explicit test_less() : data_(0) {}
25-
explicit test_less(int data) : data_(data) {}
26-
bool operator()(const T& a, const T& b) const { return a < b; }
27-
friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; }
24+
TEST_CONSTEXPR_CXX26 explicit test_less() : data_(0) {}
25+
TEST_CONSTEXPR_CXX26 explicit test_less(int data) : data_(data) {}
26+
TEST_CONSTEXPR_CXX26 bool operator()(const T& a, const T& b) const { return a < b; }
27+
TEST_CONSTEXPR_CXX26 friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; }
2828
};
2929

3030
#endif // TEST_COMPARE_H

0 commit comments

Comments
 (0)