Skip to content

Commit 8fde648

Browse files
authored
[libc++] Remove obsolete accessors in std::list and std::forward_list (#115748)
We don't need these accessors anymore now that we stopped using compressed-pair.
1 parent e589496 commit 8fde648

File tree

2 files changed

+69
-81
lines changed

2 files changed

+69
-81
lines changed

libcxx/include/forward_list

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,6 @@ protected:
503503
return pointer_traits<__begin_node_pointer>::pointer_to(const_cast<__begin_node&>(__before_begin_));
504504
}
505505

506-
_LIBCPP_HIDE_FROM_ABI __node_allocator& __alloc() _NOEXCEPT { return __alloc_; }
507-
_LIBCPP_HIDE_FROM_ABI const __node_allocator& __alloc() const _NOEXCEPT { return __alloc_; }
508-
509506
typedef __forward_list_iterator<__node_pointer> iterator;
510507
typedef __forward_list_const_iterator<__node_pointer> const_iterator;
511508

@@ -541,8 +538,7 @@ protected:
541538

542539
template <class... _Args>
543540
_LIBCPP_HIDE_FROM_ABI __node_pointer __create_node(__node_pointer __next, _Args&&... __args) {
544-
__node_allocator& __a = __alloc();
545-
__allocation_guard<__node_allocator> __guard(__a, 1);
541+
__allocation_guard<__node_allocator> __guard(__alloc_, 1);
546542
// Begin the lifetime of the node itself. Note that this doesn't begin the lifetime of the value
547543
// held inside the node, since we need to use the allocator's construct() method for that.
548544
//
@@ -552,17 +548,16 @@ protected:
552548
std::__construct_at(std::addressof(*__guard.__get()), __next);
553549

554550
// Now construct the value_type using the allocator's construct() method.
555-
__node_traits::construct(__a, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);
551+
__node_traits::construct(__alloc_, std::addressof(__guard.__get()->__get_value()), std::forward<_Args>(__args)...);
556552
return __guard.__release_ptr();
557553
}
558554

559555
_LIBCPP_HIDE_FROM_ABI void __delete_node(__node_pointer __node) {
560556
// For the same reason as above, we use the allocator's destroy() method for the value_type,
561557
// but not for the node itself.
562-
__node_allocator& __a = __alloc();
563-
__node_traits::destroy(__a, std::addressof(__node->__get_value()));
558+
__node_traits::destroy(__alloc_, std::addressof(__node->__get_value()));
564559
std::__destroy_at(std::addressof(*__node));
565-
__node_traits::deallocate(__a, __node, 1);
560+
__node_traits::deallocate(__alloc_, __node, 1);
566561
}
567562

568563
public:
@@ -579,15 +574,15 @@ protected:
579574
private:
580575
_LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base&, false_type) {}
581576
_LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __forward_list_base& __x, true_type) {
582-
if (__alloc() != __x.__alloc())
577+
if (__alloc_ != __x.__alloc_)
583578
clear();
584-
__alloc() = __x.__alloc();
579+
__alloc_ = __x.__alloc_;
585580
}
586581

587582
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base&, false_type) _NOEXCEPT {}
588583
_LIBCPP_HIDE_FROM_ABI void __move_assign_alloc(__forward_list_base& __x, true_type)
589584
_NOEXCEPT_(is_nothrow_move_assignable<__node_allocator>::value) {
590-
__alloc() = std::move(__x.__alloc());
585+
__alloc_ = std::move(__x.__alloc_);
591586
}
592587
};
593588

@@ -603,7 +598,7 @@ inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base
603598
template <class _Tp, class _Alloc>
604599
inline __forward_list_base<_Tp, _Alloc>::__forward_list_base(__forward_list_base&& __x, const allocator_type& __a)
605600
: __before_begin_(__begin_node()), __alloc_(__node_allocator(__a)) {
606-
if (__alloc() == __x.__alloc()) {
601+
if (__alloc_ == __x.__alloc_) {
607602
__before_begin()->__next_ = __x.__before_begin()->__next_;
608603
__x.__before_begin()->__next_ = nullptr;
609604
}
@@ -624,7 +619,7 @@ inline void __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
624619
_NOEXCEPT_(!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable_v<__node_allocator>)
625620
#endif
626621
{
627-
std::__swap_allocator(__alloc(), __x.__alloc());
622+
std::__swap_allocator(__alloc_, __x.__alloc_);
628623
using std::swap;
629624
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
630625
}
@@ -739,7 +734,7 @@ public:
739734

740735
_LIBCPP_HIDE_FROM_ABI void assign(size_type __n, const value_type& __v);
741736

742-
_LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(__base::__alloc()); }
737+
_LIBCPP_HIDE_FROM_ABI allocator_type get_allocator() const _NOEXCEPT { return allocator_type(this->__alloc_); }
743738

744739
_LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(__base::__before_begin()->__next_); }
745740
_LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT {
@@ -765,7 +760,7 @@ public:
765760
return __base::__before_begin()->__next_ == nullptr;
766761
}
767762
_LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT {
768-
return std::min<size_type>(__node_traits::max_size(__base::__alloc()), numeric_limits<difference_type>::max());
763+
return std::min<size_type>(__node_traits::max_size(this->__alloc_), numeric_limits<difference_type>::max());
769764
}
770765

771766
_LIBCPP_HIDE_FROM_ABI reference front() { return __base::__before_begin()->__next_->__get_value(); }
@@ -944,7 +939,7 @@ forward_list<_Tp, _Alloc>::forward_list(_InputIterator __f, _InputIterator __l,
944939

945940
template <class _Tp, class _Alloc>
946941
forward_list<_Tp, _Alloc>::forward_list(const forward_list& __x)
947-
: __base(__node_traits::select_on_container_copy_construction(__x.__alloc())) {
942+
: __base(__node_traits::select_on_container_copy_construction(__x.__alloc_)) {
948943
insert_after(cbefore_begin(), __x.begin(), __x.end());
949944
}
950945

@@ -967,7 +962,7 @@ forward_list<_Tp, _Alloc>& forward_list<_Tp, _Alloc>::operator=(const forward_li
967962
template <class _Tp, class _Alloc>
968963
forward_list<_Tp, _Alloc>::forward_list(forward_list&& __x, const __type_identity_t<allocator_type>& __a)
969964
: __base(std::move(__x), __a) {
970-
if (__base::__alloc() != __x.__alloc()) {
965+
if (this->__alloc_ != __x.__alloc_) {
971966
typedef move_iterator<iterator> _Ip;
972967
insert_after(cbefore_begin(), _Ip(__x.begin()), _Ip(__x.end()));
973968
}
@@ -994,7 +989,7 @@ void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, true_type)
994989

995990
template <class _Tp, class _Alloc>
996991
void forward_list<_Tp, _Alloc>::__move_assign(forward_list& __x, false_type) {
997-
if (__base::__alloc() == __x.__alloc())
992+
if (this->__alloc_ == __x.__alloc_)
998993
__move_assign(__x, true_type());
999994
else {
1000995
typedef move_iterator<iterator> _Ip;

0 commit comments

Comments
 (0)