From 83583bb59845a52d7cbc6e1688ea6c809396c7e8 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Thu, 3 Apr 2025 20:35:56 -0400 Subject: [PATCH 001/248] Apply initial _LIBCPP_CONSTEXPR_SINCE_CXX26 --- libcxx/include/map | 238 ++++++++++++++++++++++++++++----------------- 1 file changed, 150 insertions(+), 88 deletions(-) diff --git a/libcxx/include/map b/libcxx/include/map index e7e0c14e36999..3719efd6b6e73 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -989,10 +989,11 @@ public: protected: key_compare comp; - _LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : comp(__c) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare(key_compare __c) : comp(__c) {} public: - _LIBCPP_HIDE_FROM_ABI bool operator()(const value_type& __x, const value_type& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool + operator()(const value_type& __x, const value_type& __y) const { return comp(__x.first, __y.first); } }; @@ -1029,26 +1030,27 @@ public: template friend class _LIBCPP_TEMPLATE_VIS multimap; - _LIBCPP_HIDE_FROM_ABI map() _NOEXCEPT_( + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map() _NOEXCEPT_( is_nothrow_default_constructible::value&& is_nothrow_default_constructible::value&& is_nothrow_copy_constructible::value) : __tree_(__vc(key_compare())) {} - _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp) _NOEXCEPT_( + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const key_compare& __comp) _NOEXCEPT_( is_nothrow_default_constructible::value&& is_nothrow_copy_constructible::value) : __tree_(__vc(__comp)) {} - _LIBCPP_HIDE_FROM_ABI explicit map(const key_compare& __comp, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const key_compare& __comp, const allocator_type& __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a)) {} template - _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare()) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 + map(_InputIterator __f, _InputIterator __l, const key_compare& __comp = key_compare()) : __tree_(__vc(__comp)) { insert(__f, __l); } template - _LIBCPP_HIDE_FROM_ABI + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(_InputIterator __f, _InputIterator __l, const key_compare& __comp, const allocator_type& __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { insert(__f, __l); @@ -1056,7 +1058,7 @@ public: # if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> - _LIBCPP_HIDE_FROM_ABI + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(from_range_t, _Range&& __range, const key_compare& __comp = key_compare(), @@ -1068,19 +1070,22 @@ public: # if _LIBCPP_STD_VER >= 14 template - _LIBCPP_HIDE_FROM_ABI map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 + map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) : map(__f, __l, key_compare(), __a) {} # endif # if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> - _LIBCPP_HIDE_FROM_ABI map(from_range_t, _Range&& __range, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(from_range_t, _Range&& __range, const allocator_type& __a) : map(from_range, std::forward<_Range>(__range), key_compare(), __a) {} # endif - _LIBCPP_HIDE_FROM_ABI map(const map& __m) : __tree_(__m.__tree_) { insert(__m.begin(), __m.end()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(const map& __m) : __tree_(__m.__tree_) { + insert(__m.begin(), __m.end()); + } - _LIBCPP_HIDE_FROM_ABI map& operator=(const map& __m) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(const map& __m) { # ifndef _LIBCPP_CXX03_LANG __tree_ = __m.__tree_; # else @@ -1096,32 +1101,36 @@ public: # ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 + map(map&& __m) noexcept(is_nothrow_move_constructible<__base>::value) : __tree_(std::move(__m.__tree_)) {} - _LIBCPP_HIDE_FROM_ABI map(map&& __m, const allocator_type& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(map&& __m, const allocator_type& __a); - _LIBCPP_HIDE_FROM_ABI map& operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& + operator=(map&& __m) noexcept(is_nothrow_move_assignable<__base>::value) { __tree_ = std::move(__m.__tree_); return *this; } - _LIBCPP_HIDE_FROM_ABI map(initializer_list __il, const key_compare& __comp = key_compare()) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 + map(initializer_list __il, const key_compare& __comp = key_compare()) : __tree_(__vc(__comp)) { insert(__il.begin(), __il.end()); } - _LIBCPP_HIDE_FROM_ABI map(initializer_list __il, const key_compare& __comp, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 + map(initializer_list __il, const key_compare& __comp, const allocator_type& __a) : __tree_(__vc(__comp), typename __base::allocator_type(__a)) { insert(__il.begin(), __il.end()); } # if _LIBCPP_STD_VER >= 14 - _LIBCPP_HIDE_FROM_ABI map(initializer_list __il, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(initializer_list __il, const allocator_type& __a) : map(__il, key_compare(), __a) {} # endif - _LIBCPP_HIDE_FROM_ABI map& operator=(initializer_list __il) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map& operator=(initializer_list __il) { __tree_.__assign_unique(__il.begin(), __il.end()); return *this; } @@ -1130,43 +1139,65 @@ public: _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} - _LIBCPP_HIDE_FROM_ABI map(const map& __m, const allocator_type& __a) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(const map& __m, const allocator_type& __a) : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { insert(__m.begin(), __m.end()); } - _LIBCPP_HIDE_FROM_ABI ~map() { static_assert(sizeof(std::__diagnose_non_const_comparator<_Key, _Compare>()), ""); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~map() { + 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(); + } - _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](const key_type& __k); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](const key_type& __k); # ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI mapped_type& operator[](key_type&& __k); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& operator[](key_type&& __k); # endif - _LIBCPP_HIDE_FROM_ABI mapped_type& at(const key_type& __k); - _LIBCPP_HIDE_FROM_ABI const mapped_type& at(const key_type& __k) const; + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 mapped_type& at(const key_type& __k); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const mapped_type& at(const key_type& __k) const; - _LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__tree_.__alloc()); } - _LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __tree_.value_comp().key_comp(); } - _LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__tree_.value_comp().key_comp()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 allocator_type get_allocator() const _NOEXCEPT { + return allocator_type(__tree_.__alloc()); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 key_compare key_comp() const { + return __tree_.value_comp().key_comp(); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_compare value_comp() const { + return value_compare(__tree_.value_comp().key_comp()); + } # ifndef _LIBCPP_CXX03_LANG template @@ -1853,50 +1884,56 @@ public: # ifndef _LIBCPP_CXX03_LANG template - _LIBCPP_HIDE_FROM_ABI iterator emplace(_Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator emplace(_Args&&... __args) { return __tree_.__emplace_multi(std::forward<_Args>(__args)...); } template - _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_multi(__p.__i_, std::forward<_Args>(__args)...); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI iterator insert(_Pp&& __p) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(_Pp&& __p) { return __tree_.__insert_multi(std::forward<_Pp>(__p)); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __pos, _Pp&& __p) { return __tree_.__insert_multi(__pos.__i_, std::forward<_Pp>(__p)); } - _LIBCPP_HIDE_FROM_ABI iterator insert(value_type&& __v) { return __tree_.__insert_multi(std::move(__v)); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(value_type&& __v) { + return __tree_.__insert_multi(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_.__insert_multi(__p.__i_, std::move(__v)); } - _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list __il) { + insert(__il.begin(), __il.end()); + } # endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI iterator insert(const value_type& __v) { return __tree_.__insert_multi(__v); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const value_type& __v) { + return __tree_.__insert_multi(__v); + } - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) { return __tree_.__insert_multi(__p.__i_, __v); } template - _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __f, _InputIterator __l) { for (const_iterator __e = cend(); __f != __l; ++__f) __tree_.__insert_multi(__e.__i_, *__f); } # if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> - _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { const_iterator __end = cend(); for (auto&& __element : __range) { __tree_.__insert_multi(__end.__i_, std::forward(__element)); @@ -1904,131 +1941,156 @@ public: } # endif - _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } - _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } - _LIBCPP_HIDE_FROM_ABI size_type erase(const key_type& __k) { return __tree_.__erase_multi(__k); } - _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) { + return __tree_.erase(__p.__i_); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type erase(const key_type& __k) { + return __tree_.__erase_multi(__k); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __f, const_iterator __l) { return __tree_.erase(__f.__i_, __l.__i_); } # if _LIBCPP_STD_VER >= 17 - _LIBCPP_HIDE_FROM_ABI iterator insert(node_type&& __nh) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(node_type&& __nh) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR(__nh.empty() || __nh.get_allocator() == get_allocator(), "node_type with incompatible allocator passed to multimap::insert()"); return __tree_.template __node_handle_insert_multi(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 multimap::insert()"); return __tree_.template __node_handle_insert_multi(__hint.__i_, 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(__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(__it.__i_); } template - _LIBCPP_HIDE_FROM_ABI void merge(multimap& __source) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void + merge(multimap& __source) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); return __tree_.__node_handle_merge_multi(__source.__tree_); } template - _LIBCPP_HIDE_FROM_ABI void merge(multimap&& __source) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void + merge(multimap&& __source) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); return __tree_.__node_handle_merge_multi(__source.__tree_); } template - _LIBCPP_HIDE_FROM_ABI void merge(map& __source) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void + merge(map& __source) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); return __tree_.__node_handle_merge_multi(__source.__tree_); } template - _LIBCPP_HIDE_FROM_ABI void merge(map&& __source) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void + merge(map&& __source) { _LIBCPP_ASSERT_COMPATIBLE_ALLOCATOR( __source.get_allocator() == get_allocator(), "merging container with incompatible allocator"); return __tree_.__node_handle_merge_multi(__source.__tree_); } # endif - _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void clear() _NOEXCEPT { __tree_.clear(); } - _LIBCPP_HIDE_FROM_ABI void swap(multimap& __m) _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(multimap& __m) + _NOEXCEPT_(__is_nothrow_swappable_v<__base>) { __tree_.swap(__m.__tree_); } - _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 , 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 , 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_multi(__k); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type count(const key_type& __k) const { + return __tree_.__count_multi(__k); + } # if _LIBCPP_STD_VER >= 14 template , 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 , 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(__k); } - _LIBCPP_HIDE_FROM_ABI const_iterator lower_bound(const key_type& __k) const { return __tree_.lower_bound(__k); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator lower_bound(const key_type& __k) { + return __tree_.lower_bound(__k); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator lower_bound(const key_type& __k) const { + return __tree_.lower_bound(__k); + } # if _LIBCPP_STD_VER >= 14 template , 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(__k); } template , 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(__k); } # endif - _LIBCPP_HIDE_FROM_ABI iterator upper_bound(const key_type& __k) { return __tree_.upper_bound(__k); } - _LIBCPP_HIDE_FROM_ABI const_iterator upper_bound(const key_type& __k) const { return __tree_.upper_bound(__k); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator upper_bound(const key_type& __k) { + return __tree_.upper_bound(__k); + } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const_iterator upper_bound(const key_type& __k) const { + return __tree_.upper_bound(__k); + } # if _LIBCPP_STD_VER >= 14 template , 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(__k); } template , 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(__k); } # endif - _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair equal_range(const key_type& __k) { return __tree_.__equal_range_multi(__k); } - _LIBCPP_HIDE_FROM_ABI pair equal_range(const key_type& __k) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair + equal_range(const key_type& __k) const { return __tree_.__equal_range_multi(__k); } # if _LIBCPP_STD_VER >= 14 template , int> = 0> - _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair equal_range(const _K2& __k) { return __tree_.__equal_range_multi(__k); } template , int> = 0> - _LIBCPP_HIDE_FROM_ABI pair equal_range(const _K2& __k) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair + equal_range(const _K2& __k) const { return __tree_.__equal_range_multi(__k); } # endif From 6560dd52ad94443674334585ef8d01f59032f59c Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Thu, 3 Apr 2025 20:37:35 -0400 Subject: [PATCH 002/248] Add feature test macro --- libcxx/docs/FeatureTestMacroTable.rst | 2 ++ libcxx/include/version | 2 ++ 2 files changed, 4 insertions(+) diff --git a/libcxx/docs/FeatureTestMacroTable.rst b/libcxx/docs/FeatureTestMacroTable.rst index bbcc76b52f0a9..a72ddbdb3e67a 100644 --- a/libcxx/docs/FeatureTestMacroTable.rst +++ b/libcxx/docs/FeatureTestMacroTable.rst @@ -210,6 +210,8 @@ Status ---------------------------------------------------------- ----------------- ``__cpp_lib_constexpr_iterator`` ``201811L`` ---------------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_map`` ``202502L`` + ---------------------------------------------------------- ----------------- ``__cpp_lib_constexpr_memory`` ``201811L`` ---------------------------------------------------------- ----------------- ``__cpp_lib_constexpr_numeric`` ``201911L`` diff --git a/libcxx/include/version b/libcxx/include/version index 83ae11dabd2bc..4f94be1ca14a8 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -69,6 +69,7 @@ __cpp_lib_constexpr_complex 201711L __cpp_lib_constexpr_dynamic_alloc 201907L __cpp_lib_constexpr_functional 201907L __cpp_lib_constexpr_iterator 201811L +__cpp_lib_constexpr_map 202502L __cpp_lib_constexpr_memory 202202L 201811L // C++20 __cpp_lib_constexpr_new 202406L @@ -538,6 +539,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_bind_front 202306L # define __cpp_lib_bitset 202306L # undef __cpp_lib_constexpr_algorithms +# define __cpp_lib_constexpr_map 202502L # define __cpp_lib_constexpr_algorithms 202306L # if !defined(_LIBCPP_ABI_VCRUNTIME) # define __cpp_lib_constexpr_new 202406L From ce1a62f120212634daab4d844aec1e2ac343e4df Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Thu, 3 Apr 2025 21:20:23 -0400 Subject: [PATCH 003/248] one test to start with --- .../associative/map/map.cons/alloc.pass.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp index 52199204d7914..9b854659c38f9 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp @@ -10,7 +10,7 @@ // class map -// explicit map(const allocator_type& a); +// explicit map(const allocator_type& a); // constexpr since C++26 #include #include @@ -19,7 +19,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::less C; typedef test_allocator > A; @@ -46,6 +46,13 @@ int main(int, char**) { assert(m.get_allocator() == A()); } #endif + return true; +} +int main(int, char**) { + test(); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } From a72b619c130bfd03f50f662556989cc217c73032 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sat, 5 Apr 2025 02:00:35 -0400 Subject: [PATCH 004/248] start seeing constexpr failures for at.pass.cpp --- libcxx/include/__tree | 62 +++++++++--------- libcxx/include/map | 64 +++++++++---------- .../associative/map/map.access/at.pass.cpp | 13 +++- 3 files changed, 73 insertions(+), 66 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 9d28381c8c2ce..ff57d63f15789 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -967,39 +967,39 @@ public: typedef __tree_iterator iterator; typedef __tree_const_iterator const_iterator; - _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); - _LIBCPP_HIDE_FROM_ABI explicit __tree(const allocator_type& __a); - _LIBCPP_HIDE_FROM_ABI __tree(const value_compare& __comp, const allocator_type& __a); - _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 explicit __tree(const allocator_type& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(const value_compare& __comp, const allocator_type& __a); + _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 - _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 - _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); - _LIBCPP_HIDE_FROM_ABI __tree(__tree&& __t, const allocator_type& __a); - _LIBCPP_HIDE_FROM_ABI __tree& operator=(__tree&& __t) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree(__tree&& __t, const allocator_type& __a); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree& operator=(__tree&& __t) _NOEXCEPT_(is_nothrow_move_assignable::value && ((__node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable<__node_allocator>::value) || allocator_traits<__node_allocator>::is_always_equal::value)); - _LIBCPP_HIDE_FROM_ABI ~__tree(); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 ~__tree(); - _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(__node_traits::max_size(__node_alloc()), numeric_limits::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 && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)); @@ -1315,20 +1315,20 @@ private: }; template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) _NOEXCEPT_( is_nothrow_default_constructible<__node_allocator>::value&& is_nothrow_copy_constructible::value) : __size_(0), __value_comp_(__comp) { __begin_node() = __end_node(); } template -__tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0) { __begin_node() = __end_node(); } template -__tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) : __begin_node_(__iter_pointer()), __node_alloc_(__node_allocator(__a)), __size_(0), __value_comp_(__comp) { __begin_node() = __end_node(); } @@ -1375,7 +1375,7 @@ __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_poin } template -__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)) { value_comp() = __t.value_comp(); __copy_assign_alloc(__t); @@ -1386,7 +1386,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=( template template -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) { typedef iterator_traits<_ForwardIterator> _ITraits; typedef typename _ITraits::value_type _ItValueType; static_assert(is_same<_ItValueType, __container_value_type>::value, @@ -1406,7 +1406,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first template template -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) { typedef iterator_traits<_InputIterator> _ITraits; typedef typename _ITraits::value_type _ItValueType; static_assert( @@ -1426,7 +1426,7 @@ void __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _ } template -__tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) : __begin_node_(__iter_pointer()), __node_alloc_(__node_traits::select_on_container_copy_construction(__t.__node_alloc())), __size_(0), @@ -1435,7 +1435,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const __tree& __t) } template -__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) : __begin_node_(std::move(__t.__begin_node_)), __end_node_(std::move(__t.__end_node_)), @@ -1453,7 +1453,7 @@ __tree<_Tp, _Compare, _Allocator>::__tree(__tree&& __t) _NOEXCEPT_( } template -__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) @@ -1512,7 +1512,7 @@ void __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type) { } template -__tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=(__tree&& __t) _NOEXCEPT_(is_nothrow_move_assignable::value && ((__node_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable<__node_allocator>::value) || @@ -1522,7 +1522,7 @@ __tree<_Tp, _Compare, _Allocator>& __tree<_Tp, _Compare, _Allocator>::operator=( } template -__tree<_Tp, _Compare, _Allocator>::~__tree() { +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::~__tree() { static_assert(is_copy_constructible::value, "Comparator must be copy-constructible."); destroy(__root()); } @@ -1539,7 +1539,7 @@ void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { } template -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 && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)) @@ -1564,7 +1564,7 @@ void __tree<_Tp, _Compare, _Allocator>::swap(__tree& __t) } template -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(); diff --git a/libcxx/include/map b/libcxx/include/map index 3719efd6b6e73..3ae485f1ce029 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -1201,54 +1201,54 @@ public: # ifndef _LIBCPP_CXX03_LANG template - _LIBCPP_HIDE_FROM_ABI pair emplace(_Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair emplace(_Args&&... __args) { return __tree_.__emplace_unique(std::forward<_Args>(__args)...); } template - _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.__i_, std::forward<_Args>(__args)...); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI pair insert(_Pp&& __p) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair insert(_Pp&& __p) { return __tree_.__insert_unique(std::forward<_Pp>(__p)); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __pos, _Pp&& __p) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __pos, _Pp&& __p) { return __tree_.__insert_unique(__pos.__i_, std::forward<_Pp>(__p)); } # endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI pair insert(const value_type& __v) { return __tree_.__insert_unique(__v); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair insert(const value_type& __v) { return __tree_.__insert_unique(__v); } - _LIBCPP_HIDE_FROM_ABI iterator insert(const_iterator __p, const value_type& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert(const_iterator __p, const value_type& __v) { return __tree_.__insert_unique(__p.__i_, __v); } # ifndef _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI pair insert(value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair insert(value_type&& __v) { return __tree_.__insert_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_.__insert_unique(__p.__i_, std::move(__v)); } - _LIBCPP_HIDE_FROM_ABI void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(initializer_list __il) { insert(__il.begin(), __il.end()); } # endif template - _LIBCPP_HIDE_FROM_ABI void insert(_InputIterator __f, _InputIterator __l) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert(_InputIterator __f, _InputIterator __l) { for (const_iterator __e = cend(); __f != __l; ++__f) insert(__e.__i_, *__f); } # if _LIBCPP_STD_VER >= 23 template <_ContainerCompatibleRange _Range> - _LIBCPP_HIDE_FROM_ABI void insert_range(_Range&& __range) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void insert_range(_Range&& __range) { const_iterator __end = cend(); for (auto&& __element : __range) { insert(__end.__i_, std::forward(__element)); @@ -1259,7 +1259,7 @@ public: # if _LIBCPP_STD_VER >= 17 template - _LIBCPP_HIDE_FROM_ABI pair try_emplace(const key_type& __k, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair try_emplace(const key_type& __k, _Args&&... __args) { return __tree_.__emplace_unique_key_args( __k, std::piecewise_construct, @@ -1268,7 +1268,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI pair try_emplace(key_type&& __k, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair try_emplace(key_type&& __k, _Args&&... __args) { return __tree_.__emplace_unique_key_args( __k, std::piecewise_construct, @@ -1277,7 +1277,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator try_emplace(const_iterator __h, const key_type& __k, _Args&&... __args) { return __tree_ .__emplace_hint_unique_key_args( __h.__i_, @@ -1289,7 +1289,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator try_emplace(const_iterator __h, key_type&& __k, _Args&&... __args) { return __tree_ .__emplace_hint_unique_key_args( __h.__i_, @@ -1301,7 +1301,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI pair insert_or_assign(const key_type& __k, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair insert_or_assign(const key_type& __k, _Vp&& __v) { iterator __p = lower_bound(__k); if (__p != end() && !key_comp()(__k, __p->first)) { __p->second = std::forward<_Vp>(__v); @@ -1311,7 +1311,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI pair insert_or_assign(key_type&& __k, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair insert_or_assign(key_type&& __k, _Vp&& __v) { iterator __p = lower_bound(__k); if (__p != end() && !key_comp()(__k, __p->first)) { __p->second = std::forward<_Vp>(__v); @@ -1321,7 +1321,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert_or_assign(const_iterator __h, const key_type& __k, _Vp&& __v) { auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, __k, std::forward<_Vp>(__v)); if (!__inserted) @@ -1331,7 +1331,7 @@ public: } template - _LIBCPP_HIDE_FROM_ABI iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator insert_or_assign(const_iterator __h, key_type&& __k, _Vp&& __v) { auto [__r, __inserted] = __tree_.__emplace_hint_unique_key_args(__h.__i_, __k, std::move(__k), std::forward<_Vp>(__v)); @@ -1343,26 +1343,26 @@ public: # endif // _LIBCPP_STD_VER >= 17 - _LIBCPP_HIDE_FROM_ABI iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } - _LIBCPP_HIDE_FROM_ABI iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } - _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) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(const_iterator __p) { return __tree_.erase(__p.__i_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator erase(iterator __p) { return __tree_.erase(__p.__i_); } + _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.__i_, __l.__i_); } - _LIBCPP_HIDE_FROM_ABI void clear() _NOEXCEPT { __tree_.clear(); } + _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 map::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 map::insert()"); return __tree_.template __node_handle_insert_unique(__hint.__i_, 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(__key); } _LIBCPP_HIDE_FROM_ABI node_type extract(const_iterator __it) { @@ -1537,7 +1537,7 @@ map(initializer_list>, # ifndef _LIBCPP_CXX03_LANG template -map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) +_LIBCPP_CONSTEXPR_SINCE_CXX26 map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) : __tree_(std::move(__m.__tree_), typename __base::allocator_type(__a)) { if (__a != __m.get_allocator()) { const_iterator __e = cend(); @@ -1547,7 +1547,7 @@ map<_Key, _Tp, _Compare, _Allocator>::map(map&& __m, const allocator_type& __a) } template -_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { return __tree_ .__emplace_unique_key_args(__k, std::piecewise_construct, std::forward_as_tuple(__k), std::forward_as_tuple()) .first->__get_value() @@ -1555,7 +1555,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { } template -_Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](key_type&& __k) { // TODO investigate this clang-tidy warning. // NOLINTBEGIN(bugprone-use-after-move) return __tree_ @@ -1596,7 +1596,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::operator[](const key_type& __k) { # endif // _LIBCPP_CXX03_LANG template -_Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { __parent_pointer __parent; __node_base_pointer& __child = __tree_.__find_equal(__parent, __k); if (__child == nullptr) @@ -1605,7 +1605,7 @@ _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) { } template -const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { +_LIBCPP_CONSTEXPR_SINCE_CXX26 const _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const { __parent_pointer __parent; __node_base_pointer __child = __tree_.__find_equal(__parent, __k); if (__child == nullptr) diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index cabc9f7eb1066..26a0ad1ff1613 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -10,8 +10,8 @@ // class map -// mapped_type& at(const key_type& k); -// const mapped_type& at(const key_type& k) const; +// mapped_type& at(const key_type& k); // constexpr since C++26 +// const mapped_type& at(const key_type& k) const; // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "min_allocator.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -143,6 +143,13 @@ int main(int, char**) { assert(m.size() == 7); } #endif + return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } From c04441ebd9f2a7b685f2bead883c6efcfc8b2cba Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sat, 5 Apr 2025 02:25:01 -0400 Subject: [PATCH 005/248] member call on object outside its lifetime is not allowed in a constant expression --- libcxx/include/__tree | 139 +++++++++--------- libcxx/include/map | 56 +++---- .../associative/map/map.access/empty.pass.cpp | 11 +- .../map/map.access/empty.verify.cpp | 12 +- .../map/map.access/index_key.pass.cpp | 11 +- .../map/map.access/index_rv_key.pass.cpp | 11 +- .../map/map.access/index_tuple.pass.cpp | 11 +- .../map/map.access/iterator.pass.cpp | 33 +++-- .../map/map.access/max_size.pass.cpp | 11 +- .../associative/map/map.access/size.pass.cpp | 11 +- .../map.cons/assign_initializer_list.pass.cpp | 17 ++- .../associative/map/map.cons/compare.pass.cpp | 11 +- .../map/map.cons/compare_alloc.pass.cpp | 11 +- .../map/map.cons/copy_alloc.pass.cpp | 11 +- 14 files changed, 223 insertions(+), 133 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index ff57d63f15789..c966236e51842 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -509,10 +509,10 @@ struct __tree_key_value_types { typedef _Tp __container_value_type; static const bool __is_map = false; - _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Tp const& __v) { return __v; } - _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; } - _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); } - _LIBCPP_HIDE_FROM_ABI static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static key_type const& __get_key(_Tp const& __v) { return __v; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type const& __get_value(__node_value_type const& __v) { return __v; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type&& __move(__node_value_type& __v) { return std::move(__v); } }; template @@ -524,25 +524,25 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { typedef __container_value_type __map_value_type; static const bool __is_map = true; - _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(__node_value_type const& __t) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static key_type const& __get_key(__node_value_type const& __t) { return __t.__get_value().first; } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI static key_type const& __get_key(_Up& __t) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static key_type const& __get_key(_Up& __t) { return __t.first; } - _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(__node_value_type const& __t) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type const& __get_value(__node_value_type const& __t) { return __t.__get_value(); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI static __container_value_type const& __get_value(_Up& __t) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type const& __get_value(_Up& __t) { return __t; } - _LIBCPP_HIDE_FROM_ABI static __container_value_type* __get_ptr(__node_value_type& __n) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type* __get_ptr(__node_value_type& __n) { return std::addressof(__n.__get_value()); } @@ -626,7 +626,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 @@ -679,14 +679,14 @@ 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_, _NodeTypes::__get_ptr(__p->__value_)); if (__p) @@ -724,49 +724,49 @@ public: typedef value_type& reference; typedef typename _NodeTypes::__node_value_type_pointer pointer; - _LIBCPP_HIDE_FROM_ABI __tree_iterator() _NOEXCEPT + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator() _NOEXCEPT #if _LIBCPP_STD_VER >= 14 : __ptr_(nullptr) #endif { } - _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __get_np()->__value_; } - _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits::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_to(__get_np()->__value_); } - _LIBCPP_HIDE_FROM_ABI __tree_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator++() { __ptr_ = static_cast<__iter_pointer>( std::__tree_next_iter<__end_node_pointer>(static_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--() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_iterator& operator--() { __ptr_ = static_cast<__iter_pointer>( std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_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_(__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 static_cast<__node_pointer>(__ptr_); } template friend class __tree; template @@ -801,7 +801,7 @@ public: typedef const value_type& reference; typedef typename _NodeTypes::__const_node_value_type_pointer pointer; - _LIBCPP_HIDE_FROM_ABI __tree_const_iterator() _NOEXCEPT + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator() _NOEXCEPT #if _LIBCPP_STD_VER >= 14 : __ptr_(nullptr) #endif @@ -812,46 +812,46 @@ private: typedef __tree_iterator __non_const_iterator; public: - _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()->__value_; } - _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits::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_to(__get_np()->__value_); } - _LIBCPP_HIDE_FROM_ABI __tree_const_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator++() { __ptr_ = static_cast<__iter_pointer>( std::__tree_next_iter<__end_node_pointer>(static_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--() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator--() { __ptr_ = static_cast<__iter_pointer>( std::__tree_prev_iter<__node_base_pointer>(static_cast<__end_node_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_(__p) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT : __ptr_(__p) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const { return static_cast<__node_pointer>(__ptr_); } template friend class __tree; @@ -930,19 +930,19 @@ private: _LIBCPP_COMPRESSED_PAIR(size_type, __size_, value_compare, __value_comp_); public: - _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __iter_pointer __end_node() _NOEXCEPT { return static_cast<__iter_pointer>(pointer_traits<__end_node_ptr>::pointer_to(__end_node_)); } - _LIBCPP_HIDE_FROM_ABI __iter_pointer __end_node() const _NOEXCEPT { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __iter_pointer __end_node() const _NOEXCEPT { return static_cast<__iter_pointer>( pointer_traits<__end_node_ptr>::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 __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } - _LIBCPP_HIDE_FROM_ABI const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const __node_allocator& __node_alloc() const _NOEXCEPT { return __node_alloc_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __iter_pointer& __begin_node() _NOEXCEPT { return __begin_node_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } public: _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } @@ -1008,24 +1008,24 @@ public: #endif template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique_key_args(_Key const&, _Args&&... __args); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique_key_args(_Key const&, _Args&&... __args); template - _LIBCPP_HIDE_FROM_ABI pair __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_hint_unique_key_args(const_iterator, _Key const&, _Args&&...); template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique_impl(_Args&&... __args); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique_impl(_Args&&... __args); template - _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique_impl(const_iterator __p, _Args&&... __args); template - _LIBCPP_HIDE_FROM_ABI iterator __emplace_multi(_Args&&... __args); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_multi(_Args&&... __args); template - _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 - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique(_Pp&& __x) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique(_Pp&& __x) { return __emplace_unique_extract_key(std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>()); } @@ -1091,29 +1091,29 @@ public: return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; } - _LIBCPP_HIDE_FROM_ABI pair __insert_unique(const __container_value_type& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __insert_unique(const __container_value_type& __v) { return __emplace_unique_key_args(_NodeTypes::__get_key(__v), __v); } - _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, const __container_value_type& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_unique(const_iterator __p, const __container_value_type& __v) { return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), __v).first; } - _LIBCPP_HIDE_FROM_ABI pair __insert_unique(__container_value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __insert_unique(__container_value_type&& __v) { return __emplace_unique_key_args(_NodeTypes::__get_key(__v), std::move(__v)); } - _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, __container_value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_unique(const_iterator __p, __container_value_type&& __v) { return __emplace_hint_unique_key_args(__p, _NodeTypes::__get_key(__v), std::move(__v)).first; } template , __container_value_type>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI pair __insert_unique(_Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __insert_unique(_Vp&& __v) { return __emplace_unique(std::forward<_Vp>(__v)); } template , __container_value_type>::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI iterator __insert_unique(const_iterator __p, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_unique(const_iterator __p, _Vp&& __v) { return __emplace_hint_unique(__p, std::forward<_Vp>(__v)); } @@ -1228,13 +1228,13 @@ public: // FIXME: Make this function const qualified. Unfortunately doing so // breaks existing code which uses non-const callable comparators. template - _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v); + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v); template - _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer& __find_equal(__parent_pointer& __parent, const _Key& __v) const { return const_cast<__tree*>(this)->__find_equal(__parent, __v); } template - _LIBCPP_HIDE_FROM_ABI __node_base_pointer& + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer& __find_equal(const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v); _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) { @@ -1255,7 +1255,7 @@ private: __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v); template - _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; @@ -1667,6 +1667,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_leaf(const_iterator __hint, __parent_p // If __v exists, set parent to node of __v and return reference to node of __v template template +_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, const _Key& __v) { __node_pointer __nd = __root(); @@ -1708,6 +1709,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__parent_pointer& __parent, cons // If __v exists, set parent to node of __v and return reference to node of __v template template +_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Compare, _Allocator>::__find_equal( const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v) { if (__hint == end() || value_comp()(__v, *__hint)) // check before @@ -1766,7 +1768,7 @@ void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( template template pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) { __parent_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __k); __node_pointer __r = static_cast<__node_pointer>(__child); @@ -1783,7 +1785,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A template template pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( const_iterator __p, _Key const& __k, _Args&&... __args) { __parent_pointer __parent; __node_base_pointer __dummy; @@ -1801,6 +1803,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( template template +_LIBCPP_CONSTEXPR_SINCE_CXX26 typename __tree<_Tp, _Compare, _Allocator>::__node_holder __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { static_assert(!__is_tree_value_type<_Args...>::value, "Cannot construct from __value_type"); @@ -1814,7 +1817,7 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { template template pair::iterator, bool> -__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { __node_holder __h = __construct_node(std::forward<_Args>(__args)...); __parent_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __h->__value_); @@ -1831,7 +1834,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { template template typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p, _Args&&... __args) { __node_holder __h = __construct_node(std::forward<_Args>(__args)...); __parent_pointer __parent; __node_base_pointer __dummy; @@ -1847,7 +1850,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p template template typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { +_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { __node_holder __h = __construct_node(std::forward<_Args>(__args)...); __parent_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__h->__value_)); @@ -1858,7 +1861,7 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) { template template typename __tree<_Tp, _Compare, _Allocator>::iterator -__tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Args&&... __args) { +_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)...); __parent_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__h->__value_)); diff --git a/libcxx/include/map b/libcxx/include/map index 3ae485f1ce029..92891332c3a57 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -639,21 +639,21 @@ template ::value && !__libcpp_is_final<_Compare>::value> class __map_value_compare : private _Compare { public: - _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) : _Compare() {} - _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) : _Compare(__c) {} - _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return *this; } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const _Compare& key_comp() const _NOEXCEPT { return *this; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _CP& __y) const { return static_cast(*this)(__x.__get_value().first, __y.__get_value().first); } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _Key& __y) const { return static_cast(*this)(__x.__get_value().first, __y); } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _Key& __x, const _CP& __y) const { return static_cast(*this)(__x, __y.__get_value().first); } - _LIBCPP_HIDE_FROM_ABI void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { using std::swap; swap(static_cast<_Compare&>(*this), static_cast<_Compare&>(__y)); } @@ -868,37 +868,37 @@ public: typedef value_type& reference; typedef typename _NodeTypes::__map_value_type_pointer pointer; - _LIBCPP_HIDE_FROM_ABI __map_iterator() _NOEXCEPT {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator() _NOEXCEPT {} - _LIBCPP_HIDE_FROM_ABI __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} - _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } - _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits::pointer_to(__i_->__get_value()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __i_->__get_value(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const { return pointer_traits::pointer_to(__i_->__get_value()); } - _LIBCPP_HIDE_FROM_ABI __map_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator& operator++() { ++__i_; return *this; } - _LIBCPP_HIDE_FROM_ABI __map_iterator operator++(int) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator operator++(int) { __map_iterator __t(*this); ++(*this); return __t; } - _LIBCPP_HIDE_FROM_ABI __map_iterator& operator--() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator& operator--() { --__i_; return *this; } - _LIBCPP_HIDE_FROM_ABI __map_iterator operator--(int) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_iterator operator--(int) { __map_iterator __t(*this); --(*this); return __t; } - friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_iterator& __x, const __map_iterator& __y) { + friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const __map_iterator& __x, const __map_iterator& __y) { return __x.__i_ == __y.__i_; } - friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_iterator& __x, const __map_iterator& __y) { + friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator!=(const __map_iterator& __x, const __map_iterator& __y) { return __x.__i_ != __y.__i_; } @@ -924,39 +924,39 @@ public: typedef const value_type& reference; typedef typename _NodeTypes::__const_map_value_type_pointer pointer; - _LIBCPP_HIDE_FROM_ABI __map_const_iterator() _NOEXCEPT {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator() _NOEXCEPT {} - _LIBCPP_HIDE_FROM_ABI __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {} _LIBCPP_HIDE_FROM_ABI - __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {} + _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator(__map_iterator< typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT : __i_(__i.__i_) {} - _LIBCPP_HIDE_FROM_ABI reference operator*() const { return __i_->__get_value(); } - _LIBCPP_HIDE_FROM_ABI pointer operator->() const { return pointer_traits::pointer_to(__i_->__get_value()); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 reference operator*() const { return __i_->__get_value(); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer operator->() const { return pointer_traits::pointer_to(__i_->__get_value()); } - _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator++() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator& operator++() { ++__i_; return *this; } - _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator++(int) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator operator++(int) { __map_const_iterator __t(*this); ++(*this); return __t; } - _LIBCPP_HIDE_FROM_ABI __map_const_iterator& operator--() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator& operator--() { --__i_; return *this; } - _LIBCPP_HIDE_FROM_ABI __map_const_iterator operator--(int) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_const_iterator operator--(int) { __map_const_iterator __t(*this); --(*this); return __t; } - friend _LIBCPP_HIDE_FROM_ABI bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) { + friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator==(const __map_const_iterator& __x, const __map_const_iterator& __y) { return __x.__i_ == __y.__i_; } - friend _LIBCPP_HIDE_FROM_ABI bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) { + friend _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) { return __x.__i_ != __y.__i_; } diff --git a/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp index 21118eca69693..247ac1895b4f3 100644 --- a/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp @@ -10,7 +10,7 @@ // class map -// bool empty() const; +// bool empty() const;// constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; M m; @@ -39,6 +39,13 @@ int main(int, char**) { assert(m.empty()); } #endif +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp b/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp index f44411df0bb00..269add6089628 100644 --- a/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp @@ -10,13 +10,21 @@ // class map -// bool empty() const noexcept; +// bool empty() const noexcept;// constexpr since C++26 // UNSUPPORTED: c++03, c++11, c++14, c++17 #include -void f() { +bool test() { std::map c; c.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + return true; +} + +int main() { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif } diff --git a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp index 58610c69ed3dc..8633d522947c5 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp @@ -10,7 +10,7 @@ // class map -// mapped_type& operator[](const key_type& k); +// mapped_type& operator[](const key_type& k);// constexpr since C++26 #include #include @@ -23,7 +23,7 @@ # include "container_test_types.h" #endif -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -135,6 +135,13 @@ int main(int, char**) { assert(m.size() == 8); } #endif +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index d5d01b96a6988..f5ec0c73bd284 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -12,7 +12,7 @@ // class map -// mapped_type& operator[](key_type&& k); +// mapped_type& operator[](key_type&& k);// constexpr since C++26 #include #include @@ -23,7 +23,7 @@ #include "min_allocator.h" #include "container_test_types.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { std::map m; assert(m.size() == 0); @@ -75,6 +75,13 @@ int main(int, char**) { } } } +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp index 3f33cfd699151..565db2b6b7342 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp @@ -12,16 +12,23 @@ // class map -// mapped_type& operator[](const key_type& k); +// mapped_type& operator[](const key_type& k);// constexpr since C++26 // https://llvm.org/PR16542 #include #include -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { std::map, std::size_t> m; m[std::make_tuple(2, 3)] = 7; +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp index bbad44c8edb30..20f8541213007 100644 --- a/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp @@ -10,20 +10,20 @@ // class map -// iterator begin(); -// const_iterator begin() const; -// iterator end(); -// const_iterator end() const; +// iterator begin();// constexpr since C++26 +// const_iterator begin() const;// constexpr since C++26 +// iterator end();// constexpr since C++26 +// const_iterator end() const;// constexpr since C++26 // -// reverse_iterator rbegin(); -// const_reverse_iterator rbegin() const; -// reverse_iterator rend(); -// const_reverse_iterator rend() const; +// reverse_iterator rbegin();// constexpr since C++26 +// const_reverse_iterator rbegin() const;// constexpr since C++26 +// reverse_iterator rend();// constexpr since C++26 +// 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; +// const_iterator cbegin() const;// constexpr since C++26 +// const_iterator cend() const;// constexpr since C++26 +// const_reverse_iterator crbegin() const;// constexpr since C++26 +// const_reverse_iterator crend() const;// constexpr since C++26 #include #include @@ -32,7 +32,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = {V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), @@ -156,6 +156,13 @@ int main(int, char**) { assert(!(cii != ii1)); } #endif +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp index 1a5d35c2579d8..3a552cebd1fb4 100644 --- a/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp @@ -10,7 +10,7 @@ // class map -// size_type max_size() const; +// size_type max_size() const;// constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_allocator.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair KV; { typedef limited_allocator A; @@ -44,6 +44,13 @@ int main(int, char**) { assert(c.max_size() <= max_dist); assert(c.max_size() <= alloc_max_size(c.get_allocator())); } +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp index 23914f6b8ed16..cfb3d6e9426df 100644 --- a/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp @@ -10,7 +10,7 @@ // class map -// size_type size() const; +// size_type size() const;// constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; M m; @@ -55,6 +55,13 @@ int main(int, char**) { assert(m.size() == 0); } #endif +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp index f237c9b56deee..9b1f9730591f3 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -12,7 +12,7 @@ // class map -// map& operator=(initializer_list il); +// map& operator=(initializer_list il);// constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "min_allocator.h" #include "test_allocator.h" -void test_basic() { +TEST_CONSTEXPR_CXX26 bool test_basic() { { typedef std::pair V; std::map m = { @@ -46,9 +46,10 @@ void test_basic() { assert(*std::next(m.begin()) == V(2, 1)); assert(*std::next(m.begin(), 2) == V(3, 1)); } + return true; } -void duplicate_keys_test() { +TEST_CONSTEXPR_CXX26 bool duplicate_keys_test() { test_allocator_statistics alloc_stats; typedef std::map, test_allocator > > Map; { @@ -61,11 +62,19 @@ void duplicate_keys_test() { assert(s.begin()->first == 4); } LIBCPP_ASSERT(alloc_stats.alloc_count == 0); + return true; } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { test_basic(); duplicate_keys_test(); +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp index bd27a2f4ddeb9..66696da0fd39f 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp @@ -10,7 +10,7 @@ // class map -// explicit map(const key_compare& comp); +// explicit map(const key_compare& comp);// constexpr since C++26 #include #include @@ -19,7 +19,7 @@ #include "../../../test_compare.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef test_less C; const std::map m(C(3)); @@ -36,6 +36,13 @@ int main(int, char**) { assert(m.key_comp() == C(3)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp index 20f6a08db6a36..19b294573fc58 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp @@ -10,7 +10,7 @@ // class map -// map(const key_compare& comp, const allocator_type& a); +// map(const key_compare& comp, const allocator_type& a);// constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef test_less C; typedef test_allocator > A; @@ -50,6 +50,13 @@ int main(int, char**) { assert(m.get_allocator() == A{}); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp index aaf1be867b748..ffb99c9edd1f0 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp @@ -10,7 +10,7 @@ // class map -// map(const map& m, const allocator_type& a); +// map(const map& m, const allocator_type& a);// constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -122,6 +122,13 @@ int main(int, char**) { assert(*std::next(mo.begin(), 2) == V(3, 1)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } From ec9317e498e0f780a5e317ff1da6fe8874f0d104 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sat, 5 Apr 2025 20:28:45 -0400 Subject: [PATCH 006/248] Move past member call on object past it's lifetime --- libcxx/include/__tree | 10 ++++++++-- libcxx/include/map | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index c966236e51842..d8c22cbcb2c4e 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -543,7 +543,11 @@ struct __tree_key_value_types<__value_type<_Key, _Tp> > { } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static __container_value_type* __get_ptr(__node_value_type& __n) { - return std::addressof(__n.__get_value()); + // __n's lifetime has not begun, so calling __get_value is wrong + + // return std::addressof(__n.__get_value()); + + return __node_value_type::__get_address_of_value(__n); } _LIBCPP_HIDE_FROM_ABI static pair __move(__node_value_type& __v) { return __v.__move(); } @@ -658,6 +662,7 @@ public: __node_value_type __value_; _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } + // _LIBCPP_HIDE_FROM_ABI static _Tp& __get_value_static(__tree_node * foo) { return (foo->__value_); } ~__tree_node() = delete; __tree_node(__tree_node const&) = delete; @@ -1816,8 +1821,9 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { template template +_LIBCPP_CONSTEXPR_SINCE_CXX26 pair::iterator, bool> -_LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { +__tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) { __node_holder __h = __construct_node(std::forward<_Args>(__args)...); __parent_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, __h->__value_); diff --git a/libcxx/include/map b/libcxx/include/map index 92891332c3a57..5cefee5b0092d 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -790,6 +790,17 @@ public: # endif } + + /* + Use this helper when the lifetime of __v may not have begun, + so calling __v.__get_value() is not allowed + as per: + `note: member call on object outside its lifetime is not allowed in a constant expression` + */ + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 static value_type* __get_address_of_value(__value_type & __v) { + return std::addressof(__v.__cc_); + } + _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { value_type& __v = __get_value(); return __nc_ref_pair_type(const_cast(__v.first), __v.second); @@ -837,6 +848,13 @@ public: _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { return __cc_; } _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { return __cc_; } + + // TODO: maybe needed + // _LIBCPP_HIDE_FROM_ABI static value_type* __get_address_of_value(__value_type const& __v) { + // return std::addressof(__v.__cc_); + // } + + __value_type() = delete; __value_type(__value_type const&) = delete; __value_type& operator=(__value_type const&) = delete; From cec33fbe71a41b45008e281d523146805eb6e37d Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 00:54:56 -0400 Subject: [PATCH 007/248] Add ctor to initialize __value_type and __tree_node_base, and the object of unique_ptr --- libcxx/include/__tree | 20 ++++++++++++++++++-- libcxx/include/map | 5 ++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index d8c22cbcb2c4e..f3d36c0b9db52 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -649,7 +649,10 @@ public: _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } - ~__tree_node_base() = delete; + + // template constexpr __tree_node_base(Args && ... args) =default; + __tree_node_base() = default; + ~__tree_node_base() = default; __tree_node_base(__tree_node_base const&) = delete; __tree_node_base& operator=(__tree_node_base const&) = delete; }; @@ -664,6 +667,10 @@ public: _LIBCPP_HIDE_FROM_ABI _Tp& __get_value() { return __value_; } // _LIBCPP_HIDE_FROM_ABI static _Tp& __get_value_static(__tree_node * foo) { return (foo->__value_); } + + template constexpr __tree_node(Args && ... args): __value_{std::forward(args)...} { } + // TODO: libcxx26 + // _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node(__node_value_type && args): __value_{args} { } ~__tree_node() = delete; __tree_node(__tree_node const&) = delete; __tree_node& operator=(__tree_node const&) = delete; @@ -1814,7 +1821,16 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) { static_assert(!__is_tree_value_type<_Args...>::value, "Cannot construct from __value_type"); __node_allocator& __na = __node_alloc(); __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...); + // std::__value_type + // __h->__value_; +// std::addresof(__h->__value_); + + // __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...); + // *h is allocated as of yet, but not constructed + // TODO: -> remove (AFAIK, given only cc in the following needs space: h, h->value and h->value->cc) + __node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...); + + // __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), std::forward<_Args>(__args)...); __h.get_deleter().__value_constructed = true; return __h; } diff --git a/libcxx/include/map b/libcxx/include/map index 5cefee5b0092d..e363d2ed84c79 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -827,8 +827,11 @@ public: return *this; } + // TODO: libcxx26 + template _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type(Args && ... args): __cc_{std::forward(args)...} { } + // constexpr __value_type(value_type && args): __cc_{args} { } __value_type() = delete; - ~__value_type() = delete; + ~__value_type() = default; __value_type(const __value_type&) = delete; __value_type(__value_type&&) = delete; }; From 0574be6138c0ac6777b9e267e815335a3a76a0f3 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:00:53 -0400 Subject: [PATCH 008/248] construction works, at() fails due to throw_out_of_range --- libcxx/include/__tree | 30 +++++++++++++++--------------- libcxx/include/map | 5 +++-- libcxx/include/stdexcept | 6 +++--- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index f3d36c0b9db52..2895364af3be3 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -98,7 +98,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 -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_; } @@ -164,7 +164,7 @@ inline _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_min(_NodePtr __x) _NOEXCEPT { // Returns: pointer to the right-most node under __x. template -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_; @@ -195,7 +195,7 @@ 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 -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_); @@ -226,7 +226,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 -_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_; @@ -269,7 +269,7 @@ _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 -_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; @@ -645,9 +645,9 @@ public: __parent_pointer __parent_; bool __is_black_; - _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { return static_cast(__parent_); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer __parent_unsafe() const { return static_cast(__parent_); } - _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set_parent(pointer __p) { __parent_ = static_cast<__parent_pointer>(__p); } // template constexpr __tree_node_base(Args && ... args) =default; @@ -960,19 +960,19 @@ public: _LIBCPP_HIDE_FROM_ABI allocator_type __alloc() const _NOEXCEPT { return allocator_type(__node_alloc()); } private: - _LIBCPP_HIDE_FROM_ABI size_type& size() _NOEXCEPT { return __size_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type& size() _NOEXCEPT { return __size_; } public: - _LIBCPP_HIDE_FROM_ABI const 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 const 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 { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __root() const _NOEXCEPT { return static_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_); } @@ -1183,7 +1183,7 @@ public: template _LIBCPP_HIDE_FROM_ABI size_type __erase_multi(const _Key& __k); - _LIBCPP_HIDE_FROM_ABI void + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_node_at(__parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; template @@ -1764,7 +1764,7 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co } template -void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( +_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__insert_node_at( __parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT { __new_node->__left_ = nullptr; __new_node->__right_ = nullptr; diff --git a/libcxx/include/map b/libcxx/include/map index e363d2ed84c79..3aaccf2e0f3d9 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -774,7 +774,7 @@ private: value_type __cc_; public: - _LIBCPP_HIDE_FROM_ABI value_type& __get_value() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 value_type& __get_value() { # if _LIBCPP_STD_VER >= 17 return *std::launder(std::addressof(__cc_)); # else @@ -782,7 +782,7 @@ public: # endif } - _LIBCPP_HIDE_FROM_ABI const value_type& __get_value() const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const value_type& __get_value() const { # if _LIBCPP_STD_VER >= 17 return *std::launder(std::addressof(__cc_)); # else @@ -791,6 +791,7 @@ public: } + // TODO: possibly no longer needed /* Use this helper when the lifetime of __v may not have begun, so calling __v.__get_value() is not allowed diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept index 85e11629bd6e3..29d5083ac1c31 100644 --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -161,8 +161,8 @@ public: class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error { public: - _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {} - _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit out_of_range(const string& __s) : logic_error(__s) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit out_of_range(const char* __s) : logic_error(__s) {} # ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default; @@ -246,7 +246,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD # endif } -[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __throw_out_of_range(const char* __msg) { # if _LIBCPP_HAS_EXCEPTIONS throw out_of_range(__msg); # else From ed995a22d6d8608be504a01f52007d3866a0636c Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:14:21 -0400 Subject: [PATCH 009/248] can't intentionally throw in constexpr --- .../std/containers/associative/map/map.access/at.pass.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index 26a0ad1ff1613..130eefe990363 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -42,11 +42,16 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(4) == 4.5); assert(m.at(5) == 5.5); #ifndef TEST_HAS_NO_EXCEPTIONS + +// throwing is not allowed in constexpr +#if TEST_STD_VER < 26 try { TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) { } +#endif + #endif assert(m.at(7) == 7.5); assert(m.at(8) == 8.5); From e941811243219e2eb3637a0c5dc3ba078b9d63f4 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 10:18:29 -0400 Subject: [PATCH 010/248] note: cast from 'void *' is not allowed in a constant expression because the pointed object type 'std::__tree_node, min_pointer>' is not similar to the target type 'std::__tree_node_base>' --- libcxx/include/__tree | 4 ++-- .../std/containers/associative/map/map.access/at.pass.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 2895364af3be3..cfdd1f6ca8f2b 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1270,7 +1270,7 @@ private: _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; + _LIBCPP_HIDDEN _LIBCPP_CONSTEXPR_SINCE_CXX26 void destroy(__node_pointer __nd) _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type); _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_( @@ -1540,7 +1540,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::~__tree() { } template -void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { +_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT { if (__nd != nullptr) { destroy(static_cast<__node_pointer>(__nd->__left_)); destroy(static_cast<__node_pointer>(__nd->__right_)); diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index 130eefe990363..3a761dd109410 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -75,13 +75,15 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(3) == 3.5); assert(m.at(4) == 4.5); assert(m.at(5) == 5.5); -#ifndef TEST_HAS_NO_EXCEPTIONS +// throwing is not allowed in constexpr +#if TEST_STD_VER < 26 try { TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) { } #endif + assert(m.at(7) == 7.5); assert(m.at(8) == 8.5); assert(m.size() == 7); From def82612573b3b5fe13dac573e58f6dd12c8b347 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 14:24:43 -0400 Subject: [PATCH 011/248] note: cast from 'void *' is not allowed in a constant expression because the pointed object type 'std::__tree_node, min_pointer>' is not similar to the target type 'std::__tree_node_base> --- libcxx/include/__tree | 53 +++++++++++++++++++ .../associative/map/map.access/at.pass.cpp | 20 +++++++ 2 files changed, 73 insertions(+) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index cfdd1f6ca8f2b..bcc0b58c464f2 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1800,12 +1800,65 @@ pair::iterator, bool> _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args( const_iterator __p, _Key const& __k, _Args&&... __args) { __parent_pointer __parent; + // std::__tree_end_node *> __node_base_pointer __dummy; + // min_pointer>> + __node_base_pointer& __child = __find_equal(__p, __parent, __dummy, __k); __node_pointer __r = static_cast<__node_pointer>(__child); bool __inserted = false; if (__child == nullptr) { __node_holder __h = __construct_node(std::forward<_Args>(__args)...); + // std::unique_ptr, min_pointer>, std::__tree_node_destructor, min_pointer>>>> + + // *h + // std::__tree_node, min_pointer> + // (*__h).fooooo; + // std::__tree_node, min_pointer> + + // __h.get().foooooo; + // min_pointer, min_pointer>> + + // __node_base_pointer = min_pointer>> + // __h.get() = min_pointer, min_pointer>> + + + // static_assert(); + + // __tree_node::__node_value_type = std::__value_type + + /* + without 233 + no matching conversion for static_cast + from 'pointer' (aka + 'min_pointer, min_pointer>>>' + ) + to '__node_base_pointer' (aka + 'min_pointer>>, std::integral_constant>' + ) + */ + + + + + [[maybe_unused]] __node_base_pointer foo = static_cast<__node_base_pointer>(__h.get()); + // [[maybe_unused]] __node_base_pointer foo2 = __node_base_pointer(__h.get()); + + + + + /* + note: + cast from 'void *' is not allowed in a constant expression + because the pointed object type + 'std::__tree_node, min_pointer>' + is not similar to the target type + 'std::__tree_node_base>' + */ + +// i believe this cast fails because the lifetime of __h.get() has not begun + + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); __r = __h.release(); __inserted = true; diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index 3a761dd109410..98235061da5c8 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include "min_allocator.h" #include "test_macros.h" @@ -100,6 +101,25 @@ TEST_CONSTEXPR_CXX26 bool test() { V(7, 7.5), V(8, 8.5), }; + + // std::__tree_node, min_pointer> d; + // std::__tree_node_base> b = d; + using Base = std::__tree_node_base>; + + using Derived = std::__tree_node, min_pointer> ; + static_assert(std::is_base_of_v); + + + using BaseP = min_pointer; + using DerivedP = min_pointer; + // static_assert(std::is_base_of_v); + DerivedP dp(nullptr); + + BaseP bp =static_cast(dp); + (void)bp; + + + std::map, min_allocator> m(ar, ar + sizeof(ar) / sizeof(ar[0])); assert(m.size() == 7); assert(m.at(1) == 1.5); From 76fcef6a8af1a009a632f453d1a53a41ca9949bb Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Sun, 6 Apr 2025 17:48:20 -0400 Subject: [PATCH 012/248] ignore min_allocator tests for now --- .../containers/associative/map/map.access/at.pass.cpp | 3 ++- libcxx/test/support/min_allocator.h | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index 98235061da5c8..a9de4a52a6260 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -89,7 +89,8 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(8) == 8.5); assert(m.size() == 7); } -#if TEST_STD_VER >= 11 +// #if TEST_STD_VER >= 11 +#ifdef VINAY_DISABLE_FOR_NOW { typedef std::pair V; V ar[] = { diff --git a/libcxx/test/support/min_allocator.h b/libcxx/test/support/min_allocator.h index 24505bbb508d6..f54f9efe7a430 100644 --- a/libcxx/test/support/min_allocator.h +++ b/libcxx/test/support/min_allocator.h @@ -248,7 +248,10 @@ class min_pointer public: min_pointer() TEST_NOEXCEPT = default; TEST_CONSTEXPR_CXX14 min_pointer(std::nullptr_t) TEST_NOEXCEPT : ptr_(nullptr) {} - TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer p) TEST_NOEXCEPT : ptr_(static_cast(p.ptr_)) {} + // TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer p) TEST_NOEXCEPT : ptr_(static_cast(p.ptr_)) {} + + // TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer p) TEST_NOEXCEPT : ptr_((p.ptr_)) {} + TEST_CONSTEXPR_CXX14 explicit min_pointer(min_pointer p) TEST_NOEXCEPT : ptr_((p)) {} TEST_CONSTEXPR_CXX14 explicit operator bool() const {return ptr_ != nullptr;} @@ -388,7 +391,8 @@ class min_allocator { public: typedef T value_type; - typedef min_pointer pointer; + // typedef min_pointer pointer; + typedef T* pointer; min_allocator() = default; template @@ -396,7 +400,8 @@ class min_allocator TEST_CONSTEXPR_CXX20 pointer allocate(std::size_t n) { return pointer(std::allocator().allocate(n)); } - TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator().deallocate(p.ptr_, n); } + // TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator().deallocate(p.ptr_, n); } + TEST_CONSTEXPR_CXX20 void deallocate(pointer p, std::size_t n) { std::allocator().deallocate(p, n); } TEST_CONSTEXPR_CXX20 friend bool operator==(min_allocator, min_allocator) {return true;} TEST_CONSTEXPR_CXX20 friend bool operator!=(min_allocator x, min_allocator y) {return !(x == y);} From 9ea718f33e44c12cc50ff92f6ee9be8403551e3d Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 18:24:21 -0400 Subject: [PATCH 013/248] at.pass.cpp works in cpp26 for some reason --- libcxx/include/stdexcept | 6 ++--- .../associative/map/map.access/at.pass.cpp | 22 +++++++++++++------ .../map/map.access/index_key.pass.cpp | 2 ++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept index 29d5083ac1c31..85e11629bd6e3 100644 --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -161,8 +161,8 @@ public: class _LIBCPP_EXPORTED_FROM_ABI out_of_range : public logic_error { public: - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit out_of_range(const string& __s) : logic_error(__s) {} - _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit out_of_range(const char* __s) : logic_error(__s) {} + _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const string& __s) : logic_error(__s) {} + _LIBCPP_HIDE_FROM_ABI explicit out_of_range(const char* __s) : logic_error(__s) {} # ifndef _LIBCPP_ABI_VCRUNTIME _LIBCPP_HIDE_FROM_ABI out_of_range(const out_of_range&) _NOEXCEPT = default; @@ -246,7 +246,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD # endif } -[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __throw_out_of_range(const char* __msg) { +[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { # if _LIBCPP_HAS_EXCEPTIONS throw out_of_range(__msg); # else diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp index a9de4a52a6260..fa3ab1434804d 100644 --- a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp @@ -89,8 +89,8 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(8) == 8.5); assert(m.size() == 7); } -// #if TEST_STD_VER >= 11 -#ifdef VINAY_DISABLE_FOR_NOW +#if TEST_STD_VER >= 11 +// #ifdef VINAY_DISABLE_FOR_NOW { typedef std::pair V; V ar[] = { @@ -111,13 +111,14 @@ TEST_CONSTEXPR_CXX26 bool test() { static_assert(std::is_base_of_v); - using BaseP = min_pointer; - using DerivedP = min_pointer; + // using BaseP = min_pointer; + // using DerivedP = min_pointer; // static_assert(std::is_base_of_v); - DerivedP dp(nullptr); + // DerivedP dp(nullptr); + // (void)dp; - BaseP bp =static_cast(dp); - (void)bp; + // BaseP bp =static_cast(dp); + // (void)bp; @@ -131,11 +132,15 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(4) == 4.5); assert(m.at(5) == 5.5); # ifndef TEST_HAS_NO_EXCEPTIONS + +// throwing is not allowed in constexpr +# if TEST_STD_VER < 26 try { TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) { } +# endif # endif assert(m.at(7) == 7.5); assert(m.at(8) == 8.5); @@ -160,11 +165,14 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m.at(4) == 4.5); assert(m.at(5) == 5.5); # ifndef TEST_HAS_NO_EXCEPTIONS +// throwing is not allowed in constexpr +# if TEST_STD_VER < 26 try { TEST_IGNORE_NODISCARD m.at(6); assert(false); } catch (std::out_of_range&) { } +# endif # endif assert(m.at(7) == 7.5); assert(m.at(8) == 8.5); diff --git a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp index 8633d522947c5..3e80d6416cfe6 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp @@ -81,6 +81,8 @@ TEST_CONSTEXPR_CXX26 bool test() { using Key = Container::key_type; using MappedType = Container::mapped_type; ConstructController* cc = getConstructController(); + ConstructController ci; + ConstructController* cc = &ci; cc->reset(); { Container c; From a38112b9596a2630e2b9ab1af71e0f8d75624e53 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 18:47:21 -0400 Subject: [PATCH 014/248] empty.verify.cpp passes --- .../associative/map/map.access/empty.verify.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp b/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp index 269add6089628..f44411df0bb00 100644 --- a/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/empty.verify.cpp @@ -10,21 +10,13 @@ // class map -// bool empty() const noexcept;// constexpr since C++26 +// bool empty() const noexcept; // UNSUPPORTED: c++03, c++11, c++14, c++17 #include -bool test() { +void f() { std::map c; c.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} - return true; -} - -int main() { - assert(test()); -#if TEST_STD_VER >= 26 - static_assert(test()); -#endif } From b9d17a971b596ddac3074f50121f4c48eda19645 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:05:03 -0400 Subject: [PATCH 015/248] index_key_.pass.cpp constexpr fixed, but other failure --- .../containers/associative/map/map.access/index_key.pass.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp index 3e80d6416cfe6..5e771026baf9c 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp @@ -74,6 +74,7 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m[6] == 6.5); assert(m.size() == 8); } + if(!TEST_IS_CONSTANT_EVALUATED) { // Use "container_test_types.h" to check what arguments get passed // to the allocator for operator[] @@ -81,8 +82,6 @@ TEST_CONSTEXPR_CXX26 bool test() { using Key = Container::key_type; using MappedType = Container::mapped_type; ConstructController* cc = getConstructController(); - ConstructController ci; - ConstructController* cc = &ci; cc->reset(); { Container c; From 7cbc6c8f93476d0c642ad55eb735692ef3836097 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:06:50 -0400 Subject: [PATCH 016/248] index_rv_key.pass.cpp constexpr fixed, but other failure --- .../containers/associative/map/map.access/index_rv_key.pass.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index f5ec0c73bd284..9b2cd70934860 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -53,6 +53,7 @@ TEST_CONSTEXPR_CXX26 bool test() { assert(m[6] == 6.5); assert(m.size() == 2); } + if(!TEST_IS_CONSTANT_EVALUATED) { // Use "container_test_types.h" to check what arguments get passed // to the allocator for operator[] From e8b0649fe7b4654354b82010d6dc478f8de91a4c Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:09:56 -0400 Subject: [PATCH 017/248] fix index_tuple.pass.cpp --- .../associative/map/map.access/index_tuple.pass.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp index 565db2b6b7342..180b73ff533be 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp @@ -19,6 +19,9 @@ #include #include +#include +#include "test_macros.h" + TEST_CONSTEXPR_CXX26 bool test() { std::map, std::size_t> m; m[std::make_tuple(2, 3)] = 7; @@ -26,7 +29,7 @@ return true; } int main(int, char**) { -assert(test()); + assert(test()); #if TEST_STD_VER >= 26 static_assert(test()); #endif From 5c51105acbf4348cae40792e636267bf9fef6376 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:13:41 -0400 Subject: [PATCH 018/248] fix: iterator.pass.cpp --- libcxx/include/__tree | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index bcc0b58c464f2..172602d8d43af 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -155,7 +155,7 @@ _LIBCPP_HIDE_FROM_ABI bool __tree_invariant(_NodePtr __root) { // Returns: pointer to the left-most node under __x. template -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_; @@ -183,7 +183,7 @@ _LIBCPP_HIDE_FROM_ABI _NodePtr __tree_next(_NodePtr __x) _NOEXCEPT { } template -inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEPT { +inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr _LIBCPP_CONSTEXPR_SINCE_CXX26 __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_)); From ed34a537f3773572b5742a13b58688f61c90b0e9 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:16:31 -0400 Subject: [PATCH 019/248] fix max_size.pass.cpp --- libcxx/include/__tree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 172602d8d43af..22ded21c171ee 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -957,7 +957,7 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const __iter_pointer& __begin_node() const _NOEXCEPT { return __begin_node_; } 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()); } private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 size_type& size() _NOEXCEPT { return __size_; } From 1d3b9ef5bf98f9fde765aa2c7eacc130da9e9d90 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:19:50 -0400 Subject: [PATCH 020/248] size.pass.cpp --- libcxx/include/__tree | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 22ded21c171ee..15b180b4cec25 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -325,7 +325,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_balance_after_in // nor any of its children refer to __z. end_node->__left_ // may be different than the value passed in as __root. template -_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"); @@ -1153,7 +1153,7 @@ public: _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 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 @@ -1176,12 +1176,12 @@ public: _LIBCPP_HIDE_FROM_ABI _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 - _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 - _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 _LIBCPP_CONSTEXPR_SINCE_CXX26 void __insert_node_at(__parent_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT; @@ -1979,7 +1979,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __nod } template -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; @@ -2110,7 +2110,7 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg #endif // _LIBCPP_STD_VER >= 17 template -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(); @@ -2120,7 +2120,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo } template -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); @@ -2129,7 +2129,7 @@ __tree<_Tp, _Compare, _Allocator>::erase(const_iterator __f, const_iterator __l) template template -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()) @@ -2140,7 +2140,7 @@ __tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) { template template -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 __p = __equal_range_multi(__k); size_type __r = 0; From e124b63cace93415f455910f103c7e44cb2312b6 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Mon, 7 Apr 2025 19:22:32 -0400 Subject: [PATCH 021/248] alloc.pass.cpp --- libcxx/include/map | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcxx/include/map b/libcxx/include/map index 3aaccf2e0f3d9..5d83f2c23fe6b 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -1159,7 +1159,7 @@ public: # endif // _LIBCPP_CXX03_LANG - _LIBCPP_HIDE_FROM_ABI explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit map(const allocator_type& __a) : __tree_(typename __base::allocator_type(__a)) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 map(const map& __m, const allocator_type& __a) : __tree_(__m.__tree_.value_comp(), typename __base::allocator_type(__a)) { From 938989ce0576987502d8cb11bdf51bd807c23de3 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:35:25 -0400 Subject: [PATCH 022/248] blocked on assign_initializer_list --- libcxx/include/__tree | 22 +++++++++++----------- libcxx/include/__utility/pair.h | 2 ++ libcxx/include/map | 22 ++++++++++++++++++++-- libcxx/test/std/containers/test_compare.h | 16 ++++++++-------- 4 files changed, 41 insertions(+), 21 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 15b180b4cec25..145f00070de89 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -245,7 +245,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree_left_rotate(_Nod // Effects: Makes __x->__left_ the subtree root with __x as its right child // while preserving in-order order. template -_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_; @@ -1147,7 +1147,7 @@ public: return __emplace_hint_multi(__p, std::forward<_Vp>(__v)); } - _LIBCPP_HIDE_FROM_ABI pair + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __node_assign_unique(const __container_value_type& __v, __node_pointer __dest); _LIBCPP_HIDE_FROM_ABI iterator __node_insert_multi(__node_pointer __nd); @@ -1289,22 +1289,22 @@ private: _LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {} 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) @@ -1317,8 +1317,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_; @@ -1347,7 +1347,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__tree(const va // Precondition: size() != 0 template -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()); __t->__begin_node() = __t->__end_node(); @@ -1367,7 +1367,7 @@ __tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree // __cache->right_ == nullptr // This is no longer a red-black tree template -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; @@ -1945,7 +1945,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::__emplace_hint_ } template -pair::iterator, bool> +_LIBCPP_CONSTEXPR_SINCE_CXX26 pair::iterator, bool> __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd) { __parent_pointer __parent; __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v)); diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index 1f596a87f7cc7..a9f8e6d99b18e 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -39,6 +39,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/piecewise_construct.h> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -244,6 +245,7 @@ struct _LIBCPP_TEMPLATE_VIS pair __enable_if_t::value && is_assignable::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(pair<_U1, _U2> const& __p) { + // static_assert(std::is_same_v); first = __p.first; second = __p.second; return *this; diff --git a/libcxx/include/map b/libcxx/include/map index 5d83f2c23fe6b..47fc40d8643f8 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -802,7 +802,7 @@ public: return std::addressof(__v.__cc_); } - _LIBCPP_HIDE_FROM_ABI __nc_ref_pair_type __ref() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __nc_ref_pair_type __ref() { value_type& __v = __get_value(); return __nc_ref_pair_type(const_cast(__v.first), __v.second); } @@ -823,8 +823,26 @@ public: } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI __value_type& operator=(_ValueTp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type& operator=(_ValueTp&& __v) { + // static_assert(false && std::is_same_v<_ValueTp, value_type> && !std::is_same_v<_ValueTp, _ValueTp> + // , + // "fail"); + // static_assert(std::is_same_v, "fail"); + // static_assert(std::is_same_v, "fail"); + + // note: modification of object of const-qualified type 'const int' is not allowed in a constant expression + // raised by: libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp __ref() = std::forward<_ValueTp>(__v); + // only shows up at compile time for C++26, not runtime, for C++23 + + // make a copy right now to get past above error + // __ref() = _ValueTp{__v}; + + // value_type& __this_v = __get_value(); + // const_cast(__this_v.first) = __v.first; + // disabled for now, because of above error, + // __this_v.first = std::move(__v.first); + // __this_v.second = __v.second; return *this; } diff --git a/libcxx/test/std/containers/test_compare.h b/libcxx/test/std/containers/test_compare.h index 18e0b27dc954d..0d02f86d4be13 100644 --- a/libcxx/test/std/containers/test_compare.h +++ b/libcxx/test/std/containers/test_compare.h @@ -12,19 +12,19 @@ template struct test_equal_to { int data_; - explicit test_equal_to() : data_(0) {} - explicit test_equal_to(int data) : data_(data) {} - bool operator()(const T& a, const T& b) const { return a == b; } - friend bool operator==(const test_equal_to& a, const test_equal_to& b) { return a.data_ == b.data_; } + TEST_CONSTEXPR_CXX26 explicit test_equal_to() : data_(0) {} + TEST_CONSTEXPR_CXX26 explicit test_equal_to(int data) : data_(data) {} + TEST_CONSTEXPR_CXX26 bool operator()(const T& a, const T& b) const { return a == b; } + TEST_CONSTEXPR_CXX26 friend bool operator==(const test_equal_to& a, const test_equal_to& b) { return a.data_ == b.data_; } }; template struct test_less { int data_; - explicit test_less() : data_(0) {} - explicit test_less(int data) : data_(data) {} - bool operator()(const T& a, const T& b) const { return a < b; } - friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; } + TEST_CONSTEXPR_CXX26 explicit test_less() : data_(0) {} + TEST_CONSTEXPR_CXX26 explicit test_less(int data) : data_(data) {} + TEST_CONSTEXPR_CXX26 bool operator()(const T& a, const T& b) const { return a < b; } + TEST_CONSTEXPR_CXX26 friend bool operator==(const test_less& a, const test_less& b) { return a.data_ == b.data_; } }; #endif // TEST_COMPARE_H From 7d73d59760a1016fc1c912d01da3fee1d78acb65 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 20:37:12 -0400 Subject: [PATCH 023/248] compare.pass.cpp --- libcxx/include/map | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libcxx/include/map b/libcxx/include/map index 47fc40d8643f8..e00479b735b13 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -676,34 +676,34 @@ class __map_value_compare<_Key, _CP, _Compare, false> { _Compare __comp_; public: - _LIBCPP_HIDE_FROM_ABI __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare() _NOEXCEPT_(is_nothrow_default_constructible<_Compare>::value) : __comp_() {} - _LIBCPP_HIDE_FROM_ABI __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __map_value_compare(_Compare __c) _NOEXCEPT_(is_nothrow_copy_constructible<_Compare>::value) : __comp_(__c) {} - _LIBCPP_HIDE_FROM_ABI const _Compare& key_comp() const _NOEXCEPT { return __comp_; } + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 const _Compare& key_comp() const _NOEXCEPT { return __comp_; } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _CP& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _CP& __y) const { return __comp_(__x.__get_value().first, __y.__get_value().first); } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _Key& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _Key& __y) const { return __comp_(__x.__get_value().first, __y); } - _LIBCPP_HIDE_FROM_ABI bool operator()(const _Key& __x, const _CP& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _Key& __x, const _CP& __y) const { return __comp_(__x, __y.__get_value().first); } - void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { + _LIBCPP_CONSTEXPR_SINCE_CXX26 void swap(__map_value_compare& __y) _NOEXCEPT_(__is_nothrow_swappable_v<_Compare>) { using std::swap; swap(__comp_, __y.__comp_); } # if _LIBCPP_STD_VER >= 14 template - _LIBCPP_HIDE_FROM_ABI bool operator()(const _K2& __x, const _CP& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _K2& __x, const _CP& __y) const { return __comp_(__x, __y.__get_value().first); } template - _LIBCPP_HIDE_FROM_ABI bool operator()(const _CP& __x, const _K2& __y) const { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 bool operator()(const _CP& __x, const _K2& __y) const { return __comp_(__x.__get_value().first, __y); } # endif From 30ec57ca56503b49423e3a4418fc2d3da5f926f7 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:31:17 -0400 Subject: [PATCH 024/248] Modify all tests to have TEST_CONSTEXPR_CXX26 and without --- .../associative/map/compare.pass.cpp | 11 ++++++++-- .../associative/map/get_allocator.pass.cpp | 11 ++++++++-- .../associative/map/incomplete_type.pass.cpp | 11 ++++++++-- .../associative/map/map.cons/copy.pass.cpp | 11 ++++++++-- .../map/map.cons/copy_assign.pass.cpp | 11 ++++++++-- .../associative/map/map.cons/deduct.pass.cpp | 11 ++++++++-- .../map/map.cons/deduct_const.pass.cpp | 11 ++++++++-- .../associative/map/map.cons/default.pass.cpp | 11 ++++++++-- .../map/map.cons/default_noexcept.pass.cpp | 11 ++++++++-- .../map/map.cons/dtor_noexcept.pass.cpp | 11 ++++++++-- .../map/map.cons/from_range.pass.cpp | 13 +++++++++--- .../map/map.cons/initializer_list.pass.cpp | 11 ++++++++-- .../initializer_list_compare.pass.cpp | 11 ++++++++-- .../initializer_list_compare_alloc.pass.cpp | 11 ++++++++-- .../map/map.cons/iter_iter.pass.cpp | 11 ++++++++-- .../map/map.cons/iter_iter_comp.pass.cpp | 11 ++++++++-- .../map.cons/iter_iter_comp_alloc.pass.cpp | 11 ++++++++-- .../associative/map/map.cons/move.pass.cpp | 11 ++++++++-- .../map/map.cons/move_alloc.pass.cpp | 11 ++++++++-- .../map/map.cons/move_assign.pass.cpp | 11 ++++++++-- .../map/map.cons/move_noexcept.pass.cpp | 12 ++++++++--- .../map/map.erasure/erase_if.pass.cpp | 21 ++++++++++++++++--- .../map/map.modifiers/clear.pass.cpp | 11 ++++++++-- .../map/map.modifiers/emplace.pass.cpp | 11 ++++++++-- .../map/map.modifiers/emplace_hint.pass.cpp | 11 ++++++++-- .../map/map.modifiers/erase_iter.pass.cpp | 11 ++++++++-- .../map.modifiers/erase_iter_iter.pass.cpp | 11 ++++++++-- .../map/map.modifiers/erase_key.pass.cpp | 11 ++++++++-- .../map.modifiers/extract_iterator.pass.cpp | 11 ++++++++-- .../map/map.modifiers/extract_key.pass.cpp | 11 ++++++++-- ...nd_emplace_allocator_requirements.pass.cpp | 15 +++++++++---- .../map/map.modifiers/insert_cv.pass.cpp | 11 ++++++++-- .../insert_initializer_list.pass.cpp | 11 ++++++++-- .../map/map.modifiers/insert_iter_cv.pass.cpp | 11 ++++++++-- .../map.modifiers/insert_iter_iter.pass.cpp | 11 ++++++++-- .../map/map.modifiers/insert_iter_rv.pass.cpp | 11 ++++++++-- .../map.modifiers/insert_node_type.pass.cpp | 11 ++++++++-- .../insert_node_type_hint.pass.cpp | 11 ++++++++-- .../map.modifiers/insert_or_assign.pass.cpp | 17 ++++++++++----- .../map/map.modifiers/insert_range.pass.cpp | 11 ++++++++-- .../map/map.modifiers/insert_rv.pass.cpp | 11 ++++++++-- .../map/map.modifiers/merge.pass.cpp | 2 +- .../map/map.modifiers/try.emplace.pass.cpp | 11 ++++++++-- .../map.nonmember/compare.three_way.pass.cpp | 4 ++-- .../map/map.observers/key_comp.pass.cpp | 11 ++++++++-- .../map/map.observers/value_comp.pass.cpp | 11 ++++++++-- .../associative/map/map.ops/contains.pass.cpp | 11 ++++++++-- .../map/map.ops/contains_transparent.pass.cpp | 11 ++++++++-- .../associative/map/map.ops/count0.pass.cpp | 11 ++++++++-- .../map/map.ops/count_transparent.pass.cpp | 11 ++++++++-- .../map/map.ops/equal_range.pass.cpp | 13 +++++++++--- .../map/map.ops/equal_range0.pass.cpp | 13 +++++++++--- .../map.ops/equal_range_transparent.pass.cpp | 13 +++++++++--- .../associative/map/map.ops/find.pass.cpp | 13 +++++++++--- .../associative/map/map.ops/find0.pass.cpp | 13 +++++++++--- .../map/map.ops/lower_bound.pass.cpp | 13 +++++++++--- .../map/map.ops/lower_bound0.pass.cpp | 13 +++++++++--- .../map/map.ops/upper_bound.pass.cpp | 13 +++++++++--- .../map/map.ops/upper_bound0.pass.cpp | 13 +++++++++--- .../map/map.special/member_swap.pass.cpp | 11 ++++++++-- .../map/map.special/non_member_swap.pass.cpp | 11 ++++++++-- .../map/map.special/swap_noexcept.pass.cpp | 13 +++++++++--- .../map/map.value_compare/invoke.pass.cpp | 11 ++++++++-- .../map/map.value_compare/types.pass.cpp | 11 ++++++++-- .../containers/associative/map/types.pass.cpp | 11 ++++++++-- 65 files changed, 595 insertions(+), 147 deletions(-) diff --git a/libcxx/test/std/containers/associative/map/compare.pass.cpp b/libcxx/test/std/containers/associative/map/compare.pass.cpp index cb7a64b0409fc..d07f1b0b2c7fb 100644 --- a/libcxx/test/std/containers/associative/map/compare.pass.cpp +++ b/libcxx/test/std/containers/associative/map/compare.pass.cpp @@ -10,7 +10,7 @@ // template , // class Allocator = allocator>> -// class map +// class map // constexpr since C++26 // https://llvm.org/PR16538 // https://llvm.org/PR16549 @@ -27,7 +27,7 @@ struct Key { bool operator<(const Key&) const { return false; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::map MapT; typedef MapT::iterator Iter; typedef std::pair IterBool; @@ -50,6 +50,13 @@ int main(int, char**) { assert(!result2.second); assert(map[Key(0)] == 42); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/get_allocator.pass.cpp b/libcxx/test/std/containers/associative/map/get_allocator.pass.cpp index 2dbd662d3b7ac..3f8f49e9dd649 100644 --- a/libcxx/test/std/containers/associative/map/get_allocator.pass.cpp +++ b/libcxx/test/std/containers/associative/map/get_allocator.pass.cpp @@ -10,7 +10,7 @@ // class map -// allocator_type get_allocator() const +// allocator_type get_allocator() const // constexpr since C++26 #include #include @@ -19,7 +19,7 @@ #include "test_allocator.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair ValueType; { std::allocator alloc; @@ -31,6 +31,13 @@ int main(int, char**) { const std::map, other_allocator > m(alloc); assert(m.get_allocator() == alloc); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp index 99fc612698094..401d58ef65af5 100644 --- a/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp +++ b/libcxx/test/std/containers/associative/map/incomplete_type.pass.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -// +// // constexpr since C++26 // Check that std::map 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**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp index e7a69aff0b036..3f663d74876b3 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp @@ -10,7 +10,7 @@ // class map -// map(const map& m); +// map(const map& m); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -122,6 +122,13 @@ int main(int, char**) { assert(*std::next(mo.begin(), 2) == V(3, 1)); } #endif + return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp index 07c8bab2f201d..f6f4232d98a26 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -10,7 +10,7 @@ // class map -// map& operator=(const map& m); +// map& operator=(const map& m); // constexpr since C++26 #include #include @@ -131,7 +131,7 @@ bool balanced_allocs() { } #endif -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = {V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2)}; @@ -292,6 +292,13 @@ int main(int, char**) { } assert(balanced_allocs()); #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/deduct.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/deduct.pass.cpp index c91fe4b23566a..095ffbe26cb7d 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/deduct.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/deduct.pass.cpp @@ -33,7 +33,7 @@ // template // map(from_range_t, R&&, Allocator) // -> map, range-mapped-type, less>, Allocator>; // C++23 - + // constexpr since C++26 #include // std::equal #include #include @@ -48,7 +48,7 @@ using P = std::pair; using PC = std::pair; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { const P arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}}; std::map m(std::begin(arr), std::end(arr)); @@ -192,6 +192,13 @@ int main(int, char**) { #endif AssociativeContainerDeductionGuidesSfinaeAway>(); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/deduct_const.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/deduct_const.pass.cpp index dcc2d4510bcb6..1369b0bcce230 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/deduct_const.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/deduct_const.pass.cpp @@ -24,7 +24,7 @@ // template // map(initializer_list, Allocator) // -> map, Allocator>; - + // constexpr since C++26 #include // std::equal #include #include // INT_MAX @@ -39,7 +39,7 @@ using P = std::pair; using PC = std::pair; using PCC = std::pair; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { const PCC arr[] = {{1, 1L}, {2, 2L}, {1, 1L}, {INT_MAX, 1L}, {3, 1L}}; std::map m(std::begin(arr), std::end(arr)); @@ -102,6 +102,13 @@ int main(int, char**) { assert(std::equal(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 45); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp index 1b48370387a8f..cd3f73cc4720f 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp @@ -10,7 +10,7 @@ // class map -// map(); +// map(); // constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { std::map m; assert(m.empty()); @@ -50,6 +50,13 @@ int main(int, char**) { assert(m.begin() == m.end()); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index 1e43a893d66c1..9a2f6fee984e7 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -12,7 +12,7 @@ // noexcept( // is_nothrow_default_constructible::value && // is_nothrow_default_constructible::value && -// is_nothrow_copy_constructible::value); +// is_nothrow_copy_constructible::value); // constexpr since C++26 // This tests a conforming extension @@ -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() { typedef std::pair V; #if defined(_LIBCPP_VERSION) { @@ -52,6 +52,13 @@ int main(int, char**) { typedef std::map> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index 8497b942ad8eb..591f39fc979e6 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -8,7 +8,7 @@ // -// ~map() // implied noexcept; +// ~map() // implied noexcept; // constexpr since C++26 // UNSUPPORTED: c++03 @@ -26,7 +26,7 @@ struct some_comp { bool operator()(const T&, const T&) const noexcept { return false; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair V; { typedef std::map C; @@ -46,6 +46,13 @@ int main(int, char**) { static_assert(!std::is_nothrow_destructible::value, ""); } #endif // _LIBCPP_VERSION +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/from_range.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/from_range.pass.cpp index dc06266064a8d..ef04ffee5941f 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/from_range.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/from_range.pass.cpp @@ -9,11 +9,11 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // template R> -// map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 +// map(from_range_t, R&& rg, const Compare& comp = Compare(), const Allocator& = Allocator()); // C++23 // constexpr since C++26 // // template R> // map(from_range_t, R&& rg, const Allocator& a)) -// : map(from_range, std::forward(rg), Compare(), a) { } // C++23 +// : map(from_range, std::forward(rg), Compare(), a) { } // C++23 // constexpr since C++26 #include #include @@ -30,7 +30,7 @@ void test_duplicates() { assert(std::ranges::is_permutation(expected, c)); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { using T = std::pair; for_all_iterators_and_allocators([]() { test_associative_map, Alloc>(); @@ -42,6 +42,13 @@ int main(int, char**) { test_map_exception_safety_throwing_copy(); test_map_exception_safety_throwing_allocator(); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp index b18dc5cf754a0..0597e3944b630 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp @@ -12,7 +12,7 @@ // class map -// map(initializer_list il); +// map(initializer_list il); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; std::map m = {{1, 1}, {1, 1.5}, {1, 2}, {2, 1}, {2, 1.5}, {2, 2}, {3, 1}, {3, 1.5}, {3, 2}}; @@ -40,6 +40,13 @@ int main(int, char**) { assert(*std::next(m.begin()) == V(2, 1)); assert(*std::next(m.begin(), 2) == V(3, 1)); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp index 301384362bfe7..e9a8b05451f22 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp @@ -12,7 +12,7 @@ // class map -// map(initializer_list il, const key_compare& comp); +// map(initializer_list il, const key_compare& comp); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "../../../test_compare.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef test_less C; @@ -44,6 +44,13 @@ int main(int, char**) { assert(*std::next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp index da138ebd9ae61..73a80288504b9 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp @@ -12,7 +12,7 @@ // class map -// map(initializer_list il, const key_compare& comp, const allocator_type& a); +// map(initializer_list il, const key_compare& comp, const allocator_type& a); // constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef test_less C; @@ -80,6 +80,13 @@ int main(int, char**) { assert(m.key_comp() == C(3)); assert(m.get_allocator() == a); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp index c8ed1413c3084..59d8ae9316dc4 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp @@ -11,7 +11,7 @@ // class map // template -// map(InputIterator first, InputIterator last); +// map(InputIterator first, InputIterator last); // constexpr since C++26 #include #include @@ -19,7 +19,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -63,6 +63,13 @@ int main(int, char**) { assert(*std::next(m.begin(), 2) == V(3, 1)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp index f8ecee04a528a..91dedf7e15a53 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp @@ -11,7 +11,7 @@ // class map // template -// map(InputIterator first, InputIterator last, const key_compare& comp); +// map(InputIterator first, InputIterator last, const key_compare& comp); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "../../../test_compare.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -67,6 +67,13 @@ int main(int, char**) { assert(*std::next(m.begin(), 2) == V(3, 1)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index 862b07bb11731..8c84e1967c324 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -12,7 +12,7 @@ // template // map(InputIterator first, InputIterator last, -// const key_compare& comp, const allocator_type& a); +// const key_compare& comp, const allocator_type& a); // constexpr since C++26 #include #include @@ -22,7 +22,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; V ar[] = { @@ -115,6 +115,13 @@ int main(int, char**) { } # endif #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp index d33ef527c91de..a0d0a37945ccf 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp @@ -12,7 +12,7 @@ // class map -// map(map&& m); +// map(map&& m); // constexpr since C++26 #include #include @@ -22,7 +22,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair V; { typedef test_less C; @@ -114,6 +114,13 @@ int main(int, char**) { assert(mo.size() == 0); assert(std::distance(mo.begin(), mo.end()) == 0); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp index 886a4fa714d89..2fc6e9c244946 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp @@ -12,7 +12,7 @@ // class map -// map(map&& m, const allocator_type& a); +// map(map&& m, const allocator_type& a); // constexpr since C++26 #include #include @@ -25,7 +25,7 @@ #include "min_allocator.h" #include "Counter.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::pair VC; @@ -150,6 +150,13 @@ int main(int, char**) { assert(m3.key_comp() == C(5)); LIBCPP_ASSERT(m1.empty()); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp index 94f991976d6ad..520f623751680 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp @@ -12,7 +12,7 @@ // class map -// map& operator=(map&& m); +// map& operator=(map&& m); // constexpr since C++26 #include #include @@ -23,7 +23,7 @@ #include "test_allocator.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::pair VC; @@ -96,6 +96,13 @@ int main(int, char**) { assert(m3.key_comp() == C(5)); assert(m1.empty()); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index 06316ccf0901a..9814c30b74513 100644 --- a/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -10,7 +10,7 @@ // map(map&&) // noexcept(is_nothrow_move_constructible::value && -// is_nothrow_move_constructible::value); +// is_nothrow_move_constructible::value); // constexpr since C++26 // This tests a conforming extension @@ -30,7 +30,8 @@ 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::pair V; { @@ -50,6 +51,11 @@ int main(int, char**) { typedef std::map> C; static_assert(!std::is_nothrow_move_constructible::value, ""); } - +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp b/libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp index ccfd800cafde0..3d8ff6454598f 100644 --- a/libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp @@ -11,7 +11,7 @@ // template // typename map::size_type -// erase_if(map& c, Predicate pred); +// erase_if(map& c, Predicate pred); // constexpr since C++26 #include @@ -36,8 +36,9 @@ void test0(Init vals, Pred p, Init expected, std::size_t expected_erased_count) assert(s == make(expected)); } +TEST_CONSTEXPR_CXX26 template -void test() { +bool test() { auto is1 = [](auto v) { return v.first == 1; }; auto is2 = [](auto v) { return v.first == 2; }; auto is3 = [](auto v) { return v.first == 3; }; @@ -61,9 +62,13 @@ void test() { test0({1, 2, 3}, True, {}, 3); test0({1, 2, 3}, False, {1, 2, 3}, 0); + + return true; } -int main(int, char**) { + +TEST_CONSTEXPR_CXX26 +bool test_upper() { test>(); test, min_allocator>>>(); test, test_allocator>>>(); @@ -71,5 +76,15 @@ int main(int, char**) { test>(); test>(); + return true; +} + +int main(int, char**) { + +assert(test_upper()); +#if TEST_STD_VER >= 26 + static_assert(test_upper()); +#endif + return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp index 938f22eb880a6..7648371d8b77f 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp @@ -10,7 +10,7 @@ // class map -// void clear() noexcept; +// void clear() noexcept; // constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair P; @@ -59,6 +59,13 @@ int main(int, char**) { assert(m.size() == 0); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp index 36b073c2b551e..a965fde810880 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp @@ -13,7 +13,7 @@ // class map // template -// pair emplace(Args&&... args); +// pair emplace(Args&&... args); // constexpr since C++26 #include #include @@ -24,7 +24,7 @@ #include "DefaultOnly.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair R; @@ -149,6 +149,13 @@ int main(int, char**) { assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp index 56d1c5c2b90ac..d8ba2c40ba6fd 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp @@ -13,7 +13,7 @@ // class map // template -// iterator emplace_hint(const_iterator position, Args&&... args); +// iterator emplace_hint(const_iterator position, Args&&... args); // constexpr since C++26 #include #include @@ -23,7 +23,7 @@ #include "DefaultOnly.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef M::iterator R; @@ -134,6 +134,13 @@ int main(int, char**) { assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp index 9a0cf9bd21cee..96155f30d8463 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp @@ -10,7 +10,7 @@ // class map -// iterator erase(const_iterator position); +// iterator erase(const_iterator position); // constexpr since C++26 #include #include @@ -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::map M; typedef std::pair P; @@ -252,6 +252,13 @@ int main(int, char**) { c.erase(it); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp index 671f114951fc4..4b460e194020b 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp @@ -10,7 +10,7 @@ // class map -// iterator erase(const_iterator first, const_iterator last); +// iterator erase(const_iterator first, const_iterator last); // constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair P; @@ -151,6 +151,13 @@ int main(int, char**) { assert(i == m.end()); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp index f276467d97029..704721e62dad7 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp @@ -10,7 +10,7 @@ // class map -// size_type erase(const key_type& k); +// size_type erase(const key_type& k); // constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair P; @@ -269,6 +269,13 @@ int main(int, char**) { assert(s == 1); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp index db360cb8fe701..468e87cce1312 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp @@ -12,7 +12,7 @@ // class map -// node_type extract(const_iterator); +// node_type extract(const_iterator); // constexpr since C++26 #include #include "test_macros.h" @@ -39,7 +39,7 @@ void test(Container& c) { assert(c.size() == 0); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { using map_type = std::map; map_type m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}}; @@ -58,6 +58,13 @@ int main(int, char**) { min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}}; test(m); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp index 7ad9558c90c07..75e5ff6c7b47f 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp @@ -12,7 +12,7 @@ // class map -// node_type extract(key_type const&); +// node_type extract(key_type const&); // constexpr since C++26 #include #include "test_macros.h" @@ -43,7 +43,7 @@ void test(Container& c, KeyTypeIter first, KeyTypeIter last) { } } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { std::map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}}; int keys[] = {1, 2, 3, 4, 5, 6}; @@ -66,6 +66,13 @@ int main(int, char**) { int keys[] = {1, 2, 3, 4, 5, 6}; test(m, std::begin(keys), std::end(keys)); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp index 5dfd415e4382e..28a013f24c126 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp @@ -10,9 +10,9 @@ // class map -// insert(...); -// emplace(...); -// emplace_hint(...); +// insert(...); // constexpr since C++26 +// emplace(...); // constexpr since C++26 +// emplace_hint(...); // constexpr since C++26 // UNSUPPORTED: c++03 @@ -22,11 +22,18 @@ #include "container_test_types.h" #include "../../../map_allocator_requirement_test_templates.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { testMapInsert >(); testMapInsertHint >(); testMapEmplace >(); testMapEmplaceHint >(); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp index e845461cfbf31..7a8ea624c6d03 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp @@ -10,7 +10,7 @@ // class map -// pair insert(const value_type& v); +// pair insert(const value_type& v); // constexpr since C++26 #include #include @@ -58,7 +58,7 @@ void do_insert_cv_test() { assert(r.first->second == 3.5); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { do_insert_cv_test >(); #if TEST_STD_VER >= 11 { @@ -66,6 +66,13 @@ int main(int, char**) { do_insert_cv_test(); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp index 1f6e5c6371a11..4b3073e667dbc 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp @@ -12,7 +12,7 @@ // class map -// void insert(initializer_list il); +// void insert(initializer_list il); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; std::map m = {{1, 1}, {1, 1.5}, {1, 2}, {3, 1}, {3, 1.5}, {3, 2}}; @@ -49,6 +49,13 @@ int main(int, char**) { assert(*std::next(m.begin()) == V(2, 1)); assert(*std::next(m.begin(), 2) == V(3, 1)); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp index 5256ca2c8d451..cc0806de406fa 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp @@ -10,7 +10,7 @@ // class map -// iterator insert(const_iterator position, const value_type& v); +// iterator insert(const_iterator position, const value_type& v); // constexpr since C++26 #include #include @@ -54,7 +54,7 @@ void do_insert_iter_cv_test() { assert(r->second == 3.5); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { do_insert_iter_cv_test >(); #if TEST_STD_VER >= 11 { @@ -62,6 +62,13 @@ int main(int, char**) { do_insert_iter_cv_test(); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp index 0baff65f61938..db0a3df299ed0 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp @@ -11,7 +11,7 @@ // class map // template -// void insert(InputIterator first, InputIterator last); +// void insert(InputIterator first, InputIterator last); // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "test_iterators.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair P; @@ -71,6 +71,13 @@ int main(int, char**) { assert(std::next(m.begin(), 2)->second == 1); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 5d72bae39bad1..c054c0aa60a35 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -13,7 +13,7 @@ // class map // template -// iterator insert(const_iterator position, P&& p); +// iterator insert(const_iterator position, P&& p); // constexpr since C++26 #include #include @@ -52,7 +52,7 @@ void do_insert_iter_rv_test() { assert(r->first == 3); assert(r->second == 3); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { do_insert_iter_rv_test, std::pair>(); do_insert_iter_rv_test, std::pair>(); @@ -91,6 +91,13 @@ int main(int, char**) { assert(r->first == 3); assert(r->second == 3); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp index 1875c3635d9d2..27acf2c663d90 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp @@ -12,7 +12,7 @@ // class map -// insert_return_type insert(node_type&&); +// insert_return_type insert(node_type&&); // constexpr since C++26 #include #include @@ -96,11 +96,18 @@ void test(Container& c) { } } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { std::map m; test(m); std::map, min_allocator>> m2; test(m2); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp index f7db47173bc3b..cfe351c7d515d 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp @@ -12,7 +12,7 @@ // class map -// iterator insert(const_iterator hint, node_type&&); +// iterator insert(const_iterator hint, node_type&&); // constexpr since C++26 #include #include "test_macros.h" @@ -50,11 +50,18 @@ void test(Container& c) { } } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { std::map m; test(m); std::map, min_allocator>> m2; test(m2); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp index 8a129b0295180..38669bd4fe807 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp @@ -13,13 +13,13 @@ // class map // template -// pair insert_or_assign(const key_type& k, M&& obj); // C++17 +// pair insert_or_assign(const key_type& k, M&& obj); // C++17 // constexpr since C++26 // template -// pair insert_or_assign(key_type&& k, M&& obj); // C++17 +// pair insert_or_assign(key_type&& k, M&& obj); // C++17 // constexpr since C++26 // template -// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 +// iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj); // C++17 // constexpr since C++26 // template -// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 +// iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 // constexpr since C++26 #include #include @@ -57,7 +57,7 @@ class Moveable { bool moved() const { return int_ == -1; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { // pair insert_or_assign(const key_type& k, M&& obj); typedef std::map M; typedef std::pair R; @@ -282,6 +282,13 @@ int main(int, char**) { assert(r->first.get() == 11); // key assert(r->second.get() == 13); // value } +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp index 95d8897cea282..f5b7178521438 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_range.pass.cpp @@ -13,14 +13,14 @@ // // template R> -// void insert_range(R&& rg); // C++23 +// void insert_range(R&& rg); // C++23 // constexpr since C++26 #include #include "../../../insert_range_maps_sets.h" #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { // Note: we want to use a pair with non-const elements for input (an assignable type is a lot more convenient) but // have to use the exact `value_type` of the map (that is, `pair`) for the allocator. using Pair = std::pair; @@ -35,6 +35,13 @@ int main(int, char**) { test_map_insert_range_exception_safety_throwing_copy(); test_assoc_map_insert_range_exception_safety_throwing_allocator(); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp index 345bfde531cf9..7e8c25ab4c76e 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -14,7 +14,7 @@ // pair insert( value_type&& v); // C++17 and later // template -// pair insert(P&& p); +// pair insert(P&& p); // constexpr since C++26 #include #include @@ -58,7 +58,7 @@ void do_insert_rv_test() { assert(r.first->second == 3); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { do_insert_rv_test, std::pair>(); do_insert_rv_test, std::pair>(); @@ -101,6 +101,13 @@ int main(int, char**) { assert(r.first->first == 3); assert(r.first->second == 3); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/merge.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/merge.pass.cpp index 3613acfa18c1d..618b2ea7f3930 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/merge.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/merge.pass.cpp @@ -117,7 +117,7 @@ int main(int, char**) { assert(map_equal(second, {{2, 0}, {3, 0}})); assert(map_equal(third, {{1, 0}, {3, 0}})); - assert(Counter_base::gConstructed == 8); + assert(Counter_base::gConstructed == 8); } assert(Counter_base::gConstructed == 0); } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp index a087704fb4daf..83dbd62130f26 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp @@ -19,7 +19,7 @@ // template // iterator try_emplace(const_iterator hint, const key_type& k, Args&&... args); // C++17 // template -// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 +// iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 // constexpr since C++26 #include #include @@ -57,7 +57,7 @@ class Moveable { bool moved() const { return int_ == -1; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { // pair try_emplace(const key_type& k, Args&&... args); typedef std::map M; typedef std::pair R; @@ -178,6 +178,13 @@ int main(int, char**) { assert(r->first.get() == 3); // key assert(r->second.get() == 4); // value } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp b/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp index 0e1c57f123e58..66ef5437afb41 100644 --- a/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.nonmember/compare.three_way.pass.cpp @@ -14,14 +14,14 @@ // template // synth-three-way-result> // operator<=>(const map& x, -// const map& y); +// const map& y); // constexpr since C++26 #include #include #include "test_container_comparisons.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() {} assert(test_ordered_map_container_spaceship()); // `std::map` is not constexpr, so no `static_assert` test here. return 0; diff --git a/libcxx/test/std/containers/associative/map/map.observers/key_comp.pass.cpp b/libcxx/test/std/containers/associative/map/map.observers/key_comp.pass.cpp index f0757ab47ee48..c79720ce2bee9 100644 --- a/libcxx/test/std/containers/associative/map/map.observers/key_comp.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.observers/key_comp.pass.cpp @@ -8,13 +8,13 @@ // -// key_compare key_comp() const; +// key_compare key_comp() const; // constexpr since C++26 #include #include #include -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::map map_type; map_type m; @@ -25,6 +25,13 @@ int main(int, char**) { assert(cm.key_comp()(p1.first->first, p2.first->first)); assert(!cm.key_comp()(p2.first->first, p1.first->first)); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.observers/value_comp.pass.cpp b/libcxx/test/std/containers/associative/map/map.observers/value_comp.pass.cpp index edd1cd3c5c271..eddc1e2d3a0b5 100644 --- a/libcxx/test/std/containers/associative/map/map.observers/value_comp.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.observers/value_comp.pass.cpp @@ -8,13 +8,13 @@ // -// value_compare value_comp() const; +// value_compare value_comp() const; // constexpr since C++26 #include #include #include -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::map map_type; map_type m; @@ -25,6 +25,13 @@ int main(int, char**) { assert(cm.value_comp()(*p1.first, *p2.first)); assert(!cm.value_comp()(*p2.first, *p1.first)); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/contains.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/contains.pass.cpp index 7191d4c5e835d..2ecf221bd518f 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/contains.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/contains.pass.cpp @@ -13,7 +13,7 @@ // -// bool contains(const key_type& x) const; +// bool contains(const key_type& x) const; // constexpr since C++26 template void test(B bad, Pairs... args) { @@ -34,7 +34,7 @@ struct E { char c = 1; }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { test, std::pair >( 'e', std::make_pair('a', 10), std::make_pair('b', 11), std::make_pair('c', 12), std::make_pair('d', 13)); @@ -55,6 +55,13 @@ int main(int, char**) { test, std::pair >( -1, std::make_pair(1, E{}), std::make_pair(2, E{}), std::make_pair(3, E{}), std::make_pair(4, E{})); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/contains_transparent.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/contains_transparent.pass.cpp index f80f1a2714bfd..b6853243a1260 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/contains_transparent.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/contains_transparent.pass.cpp @@ -13,7 +13,7 @@ // -// template bool contains(const K& x) const; // C++20 +// template bool contains(const K& x) const; // C++20 // constexpr since C++26 struct Comp { using is_transparent = void; @@ -33,9 +33,16 @@ void test() { assert(!s.contains(-1)); } -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { test, int, Comp> >(); test, int, Comp> >(); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/count0.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/count0.pass.cpp index c7ba765178969..848c63df314fd 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/count0.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/count0.pass.cpp @@ -12,7 +12,7 @@ // class map -// size_type count(const key_type& k) const; +// size_type count(const key_type& k) const; // constexpr since C++26 // // The member function templates find, count, lower_bound, upper_bound, and // equal_range shall not participate in overload resolution unless the @@ -24,7 +24,7 @@ #include "test_macros.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; assert(M().count(C2Int{5}) == 0); @@ -33,6 +33,13 @@ int main(int, char**) { typedef std::map M; assert(M().count(C2Int{5}) == 0); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/count_transparent.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/count_transparent.pass.cpp index fc097c1dc672c..de2e7a0fac089 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/count_transparent.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/count_transparent.pass.cpp @@ -13,7 +13,7 @@ // class map // template -// size_type count(const K& x) const; // C++14 +// size_type count(const K& x) const; // C++14 // constexpr since C++26 #include #include @@ -29,11 +29,18 @@ struct Comp { bool operator()(int lhs, const std::pair& rhs) const { return lhs < rhs.first; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { std::map, int, Comp> s{{{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}}; auto cnt = s.count(1); assert(cnt == 3); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp index 883cd379802e6..de4f3b63a85d0 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp @@ -10,8 +10,8 @@ // class map -// pair equal_range(const key_type& k); -// pair equal_range(const key_type& k) const; +// pair equal_range(const key_type& k); // constexpr since C++26 +// pair equal_range(const key_type& k) const; // constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "private_constructor.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::map M; @@ -436,6 +436,13 @@ int main(int, char**) { assert(r.second == std::next(m.begin(), 8)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp index 75724bdb387ce..db0af6900a4fa 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp @@ -12,8 +12,8 @@ // class map -// pair equal_range(const key_type& k); -// pair equal_range(const key_type& k) const; +// pair equal_range(const key_type& k); // constexpr since C++26 +// pair equal_range(const key_type& k) const; // constexpr since C++26 // // The member function templates find, count, lower_bound, upper_bound, and // equal_range shall not participate in overload resolution unless the @@ -25,7 +25,7 @@ #include "test_macros.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; typedef std::pair P; @@ -40,6 +40,13 @@ int main(int, char**) { P result = example.equal_range(C2Int{5}); assert(result.first == result.second); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/equal_range_transparent.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/equal_range_transparent.pass.cpp index 2b651468887ea..4c00967624175 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/equal_range_transparent.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/equal_range_transparent.pass.cpp @@ -13,10 +13,10 @@ // class map // template -// pair equal_range(const K& x); // C++14 +// pair equal_range(const K& x); // C++14 // constexpr since C++26 // template // pair equal_range(const K& x) const; -// // C++14 +// // C++14 // constexpr since C++26 #include #include @@ -32,7 +32,7 @@ struct Comp { bool operator()(int lhs, const std::pair& rhs) const { return lhs < rhs.first; } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { std::map, int, Comp> s{{{2, 1}, 1}, {{1, 2}, 2}, {{1, 3}, 3}, {{1, 4}, 4}, {{2, 2}, 5}}; auto er = s.equal_range(1); @@ -44,6 +44,13 @@ int main(int, char**) { } assert(nels == 3); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp index 534d78128407d..2c7f83814d4b2 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp @@ -10,8 +10,8 @@ // class map -// iterator find(const key_type& k); -// const_iterator find(const key_type& k) const; +// iterator find(const key_type& k); // constexpr since C++26 +// const_iterator find(const key_type& k) const; // constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "private_constructor.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::map M; @@ -206,6 +206,13 @@ int main(int, char**) { assert(r == std::next(m.begin(), 8)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/find0.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/find0.pass.cpp index 9825d6c5879b1..08bbc903ff7aa 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/find0.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/find0.pass.cpp @@ -12,8 +12,8 @@ // class map -// iterator find(const key_type& k); -// const_iterator find(const key_type& k) const; +// iterator find(const key_type& k); // constexpr since C++26 +// const_iterator find(const key_type& k) const; // constexpr since C++26 // // The member function templates find, count, lower_bound, upper_bound, and // equal_range shall not participate in overload resolution unless the @@ -25,7 +25,7 @@ #include "test_macros.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; M example; @@ -36,6 +36,13 @@ int main(int, char**) { M example; assert(example.find(C2Int{5}) == example.end()); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp index 755ad36a3ba4d..00a6c17d59849 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp @@ -10,8 +10,8 @@ // class map -// iterator lower_bound(const key_type& k); -// const_iterator lower_bound(const key_type& k) const; +// iterator lower_bound(const key_type& k); // constexpr since C++26 +// const_iterator lower_bound(const key_type& k) const; // constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "private_constructor.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::map M; @@ -318,6 +318,13 @@ int main(int, char**) { assert(r == std::next(m.begin(), 8)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp index fe7fe381a86eb..98d3cafbb8761 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp @@ -12,8 +12,8 @@ // class map -// iterator lower_bound(const key_type& k); -// const_iterator lower_bound(const key_type& k) const; +// iterator lower_bound(const key_type& k); // constexpr since C++26 +// const_iterator lower_bound(const key_type& k) const; // constexpr since C++26 // // The member function templates find, count, lower_bound, upper_bound, and // equal_range shall not participate in overload resolution unless the @@ -25,7 +25,7 @@ #include "test_macros.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; M example; @@ -36,6 +36,13 @@ int main(int, char**) { M example; assert(example.lower_bound(C2Int{5}) == example.end()); } +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp index bd967e3dfb742..12821ce585c07 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp @@ -10,8 +10,8 @@ // class map -// iterator upper_bound(const key_type& k); -// const_iterator upper_bound(const key_type& k) const; +// iterator upper_bound(const key_type& k); // constexpr since C++26 +// const_iterator upper_bound(const key_type& k) const; // constexpr since C++26 #include #include @@ -20,7 +20,7 @@ #include "min_allocator.h" #include "private_constructor.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::pair V; typedef std::map M; @@ -281,6 +281,13 @@ int main(int, char**) { assert(r == std::next(m.begin(), 8)); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp index 525aa673ea74b..b2ec52b7bbbc6 100644 --- a/libcxx/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp @@ -12,8 +12,8 @@ // class map -// iterator upper_bound(const key_type& k); -// const_iterator upper_bound(const key_type& k) const; +// iterator upper_bound(const key_type& k); // constexpr since C++26 +// const_iterator upper_bound(const key_type& k) const; // constexpr since C++26 // // The member function templates find, count, lower_bound, upper_bound, and // equal_range shall not participate in overload resolution unless the @@ -25,7 +25,7 @@ #include "test_macros.h" #include "is_transparent.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map M; M example; @@ -36,6 +36,13 @@ int main(int, char**) { M example; assert(example.upper_bound(C2Int{5}) == example.end()); } +return true; +} +int main(int, char**) { + assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp index ffb74f62b8877..98764e3997d2d 100644 --- a/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp @@ -10,7 +10,7 @@ // class map -// void swap(map& m); +// void swap(map& m); // constexpr since C++26 #include #include @@ -18,7 +18,7 @@ #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair V; { typedef std::map M; @@ -108,6 +108,13 @@ int main(int, char**) { } } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp index ba390acd128f5..cd732a1cc2747 100644 --- a/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp @@ -12,7 +12,7 @@ // template // void -// swap(map& x, map& y); +// swap(map& x, map& y); // constexpr since C++26 #include #include @@ -21,7 +21,7 @@ #include "../../../test_compare.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::pair V; { typedef std::map M; @@ -165,6 +165,13 @@ int main(int, char**) { assert(m2.get_allocator() == A()); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index 118158fd45ec3..95de1e88b1982 100644 --- a/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -12,11 +12,11 @@ // void swap(map& c) // noexcept(!allocator_type::propagate_on_container_swap::value || -// __is_nothrow_swappable::value); +// __is_nothrow_swappable::value); // constexpr since C++26 // // In C++17, the standard says that swap shall have: // noexcept(allocator_traits::is_always_equal::value && -// noexcept(swap(declval(), declval()))); +// noexcept(swap(declval(), declval()))); // constexpr since C++26 // This tests a conforming extension @@ -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::pair V; { typedef std::map C; @@ -131,6 +131,13 @@ int main(int, char**) { } # endif // _LIBCPP_VERSION #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.value_compare/invoke.pass.cpp b/libcxx/test/std/containers/associative/map/map.value_compare/invoke.pass.cpp index 70fa972812cec..784dd8f5f1d6a 100644 --- a/libcxx/test/std/containers/associative/map/map.value_compare/invoke.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.value_compare/invoke.pass.cpp @@ -10,7 +10,7 @@ // class value_compare -// bool operator()( const value_type& lhs, const value_type& rhs ) const; +// bool operator()( const value_type& lhs, const value_type& rhs ) const; // constexpr since C++26 #include #include @@ -27,7 +27,7 @@ struct CallCompMember : Map::value_compare { } }; -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::map map_type; map_type m; @@ -42,6 +42,13 @@ int main(int, char**) { assert(!vc(*p2.first, *p1.first)); assert(!call_comp(*p2.first, *p1.first)); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/map.value_compare/types.pass.cpp b/libcxx/test/std/containers/associative/map/map.value_compare/types.pass.cpp index 89881baf88dca..cf54270883335 100644 --- a/libcxx/test/std/containers/associative/map/map.value_compare/types.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.value_compare/types.pass.cpp @@ -8,7 +8,7 @@ // -// class value_compare +// class value_compare // constexpr since C++26 // REQUIRES: c++03 || c++11 || c++14 @@ -17,7 +17,7 @@ #include "test_macros.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { typedef std::map map_type; typedef map_type::value_compare value_compare; typedef map_type::value_type value_type; @@ -25,6 +25,13 @@ int main(int, char**) { ASSERT_SAME_TYPE(value_compare::result_type, bool); ASSERT_SAME_TYPE(value_compare::first_argument_type, value_type); ASSERT_SAME_TYPE(value_compare::second_argument_type, value_type); +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } diff --git a/libcxx/test/std/containers/associative/map/types.pass.cpp b/libcxx/test/std/containers/associative/map/types.pass.cpp index 7832ff3efd3a4..c73080328192a 100644 --- a/libcxx/test/std/containers/associative/map/types.pass.cpp +++ b/libcxx/test/std/containers/associative/map/types.pass.cpp @@ -27,14 +27,14 @@ // typedef typename allocator_type::difference_type difference_type; // ... // }; - + // constexpr since C++26 #include #include #include "test_macros.h" #include "min_allocator.h" -int main(int, char**) { +TEST_CONSTEXPR_CXX26 bool test() { { typedef std::map C; static_assert((std::is_same::value), ""); @@ -66,6 +66,13 @@ int main(int, char**) { static_assert((std::is_same::value), ""); } #endif +return true; +} +int main(int, char**) { +assert(test()); +#if TEST_STD_VER >= 26 + static_assert(test()); +#endif return 0; } From 21c442c324d7768350fc855dd4dd3d6c3a148ef8 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:35:36 -0400 Subject: [PATCH 025/248] passing at: copy_assign.addressof.compile.pass.cpp --- libcxx/include/__tree | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 145f00070de89..9b6ee02a4dea1 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1249,16 +1249,16 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer& __find_equal(const_iterator __hint, __parent_pointer& __parent, __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()); } - _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(__parent_pointer& __parent, const key_type& __v); From 1e86d9c95d2c908ffd9e5c4898105e5f64710039 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:43:16 -0400 Subject: [PATCH 026/248] failing at copy_assign.pass.cpp only in constexpr --- libcxx/include/__tree | 1 + libcxx/include/map | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 9b6ee02a4dea1..4bfcd95eb8dcf 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1428,6 +1428,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__assign_m if (size() != 0) { _DetachedTreeCache __cache(this); for (; __cache.__get() && __first != __last; ++__first) { + // static_assert(std::is_same_v__value_), bool>, "fail"); __cache.__get()->__value_ = *__first; __node_insert_multi(__cache.__get()); __cache.__advance(); diff --git a/libcxx/include/map b/libcxx/include/map index e00479b735b13..1fb4777639288 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -807,17 +807,20 @@ public: return __nc_ref_pair_type(const_cast(__v.first), __v.second); } - _LIBCPP_HIDE_FROM_ABI __nc_rref_pair_type __move() { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __nc_rref_pair_type __move() { value_type& __v = __get_value(); return __nc_rref_pair_type(std::move(const_cast(__v.first)), std::move(__v.second)); } - _LIBCPP_HIDE_FROM_ABI __value_type& operator=(const __value_type& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type& operator=(const __value_type& __v) { __ref() = __v.__get_value(); + + // note: modification of object of const-qualified type 'const int' is not allowed in a constant expression + // raised by: libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp return *this; } - _LIBCPP_HIDE_FROM_ABI __value_type& operator=(__value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __value_type& operator=(__value_type&& __v) { __ref() = __v.__move(); return *this; } From 85e1cfc4c7286aa23d3aaf06cd74462915e58a68 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:47:06 -0400 Subject: [PATCH 027/248] pass deduct.pass.cpp --- libcxx/include/__tree | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 4bfcd95eb8dcf..f8f5f660b007a 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1044,61 +1044,61 @@ public: template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique(_First&& __f, _Second&& __s) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique(_First&& __f, _Second&& __s) { return __emplace_unique_key_args(__f, std::forward<_First>(__f), std::forward<_Second>(__s)); } template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique(_Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique(_Args&&... __args) { return __emplace_unique_impl(std::forward<_Args>(__args)...); } template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_fail_tag) { return __emplace_unique_impl(std::forward<_Pp>(__x)); } template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_self_tag) { return __emplace_unique_key_args(__x, std::forward<_Pp>(__x)); } template - _LIBCPP_HIDE_FROM_ABI pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __emplace_unique_extract_key(_Pp&& __x, __extract_key_first_tag) { return __emplace_unique_key_args(__x.first, std::forward<_Pp>(__x)); } template - _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique(const_iterator __p, _Pp&& __x) { return __emplace_hint_unique_extract_key(__p, std::forward<_Pp>(__x), __can_extract_key<_Pp, key_type>()); } template ::value, int> = 0> - _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique(const_iterator __p, _First&& __f, _Second&& __s) { return __emplace_hint_unique_key_args(__p, __f, std::forward<_First>(__f), std::forward<_Second>(__s)).first; } template - _LIBCPP_HIDE_FROM_ABI iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique(const_iterator __p, _Args&&... __args) { return __emplace_hint_unique_impl(__p, std::forward<_Args>(__args)...); } template - _LIBCPP_HIDE_FROM_ABI iterator + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_fail_tag) { return __emplace_hint_unique_impl(__p, std::forward<_Pp>(__x)); } template - _LIBCPP_HIDE_FROM_ABI iterator + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_self_tag) { return __emplace_hint_unique_key_args(__p, __x, std::forward<_Pp>(__x)).first; } template - _LIBCPP_HIDE_FROM_ABI iterator + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __emplace_hint_unique_extract_key(const_iterator __p, _Pp&& __x, __extract_key_first_tag) { return __emplace_hint_unique_key_args(__p, __x.first, std::forward<_Pp>(__x)).first; } @@ -1129,29 +1129,29 @@ public: return __emplace_hint_unique(__p, std::forward<_Vp>(__v)); } - _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(__container_value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_multi(__container_value_type&& __v) { return __emplace_multi(std::move(__v)); } - _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, __container_value_type&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_multi(const_iterator __p, __container_value_type&& __v) { return __emplace_hint_multi(__p, std::move(__v)); } template - _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(_Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_multi(_Vp&& __v) { return __emplace_multi(std::forward<_Vp>(__v)); } template - _LIBCPP_HIDE_FROM_ABI iterator __insert_multi(const_iterator __p, _Vp&& __v) { + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __insert_multi(const_iterator __p, _Vp&& __v) { return __emplace_hint_multi(__p, std::forward<_Vp>(__v)); } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pair __node_assign_unique(const __container_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); _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 iterator __remove_node_pointer(__node_pointer) _NOEXCEPT; @@ -1962,7 +1962,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_ } template -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) { __parent_pointer __parent; __node_base_pointer& __child = __find_leaf_high(__parent, _NodeTypes::__get_key(__nd->__value_)); @@ -1971,7 +1971,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) { } template -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) { __parent_pointer __parent; __node_base_pointer& __child = __find_leaf(__p, __parent, _NodeTypes::__get_key(__nd->__value_)); From 6ebe12c250211a758ee8275843e6bc0cd303ee67 Mon Sep 17 00:00:00 2001 From: Vinay Deshmukh <32487576+vinay-deshmukh@users.noreply.github.com> Date: Tue, 8 Apr 2025 21:57:00 -0400 Subject: [PATCH 028/248] fix map.cons/from_range.pass.cpp --- .../associative/from_range_associative_containers.h | 10 +++++----- .../associative/map/map.cons/from_range.pass.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 8 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..961b91dd6accc 100644 --- a/libcxx/test/std/containers/associative/from_range_associative_containers.h +++ b/libcxx/test/std/containers/associative/from_range_associative_containers.h @@ -60,7 +60,7 @@ template