_GLIBCXX_DEBUG container code cleanup to get rid of _Safe_container<>::_M_safe() and just
use _Safe:: calls which use normal inheritance. Also remove several usages of _M_base()
which can be most of the time ommitted and sometimes replace with explicit _Base::
calls.
libstdc++-v3/ChangeLog:
* include/debug/safe_container.h (_Safe_container<>::_M_safe): Remove.
* include/debug/deque (deque::operator=(initializer_list<>)): Replace
_M_base() call with _Base:: call.
(deque::operator[](size_type)): Likewise.
* include/debug/forward_list (forward_list(forward_list&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(forward_list::operator=(initializer_list<>)): Remove _M_base() calls.
(forward_list::splice_after, forward_list::merge): Likewise.
* include/debug/list (list(list&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(list::operator=(initializer_list<>)): Remove _M_base() calls.
(list::splice, list::merge): Likewise.
* include/debug/map.h (map(map&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(map::operator=(initializer_list<>)): Remove _M_base() calls.
* include/debug/multimap.h (multimap(multimap&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(multimap::operator=(initializer_list<>)): Remove _M_base() calls.
* include/debug/set.h (set(set&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(set::operator=(initializer_list<>)): Remove _M_base() calls.
* include/debug/multiset.h (multiset(multiset&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(multiset::operator=(initializer_list<>)): Remove _M_base() calls.
* include/debug/string (basic_string(basic_string&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(basic_string::operator=(initializer_list<>)): Remove _M_base() call.
(basic_string::operator=(const _CharT*), basic_string::operator=(_CharT)): Likewise.
(basic_string::operator[](size_type), basic_string::operator+=(const basic_string&)):
Likewise.
(basic_string::operator+=(const _Char*), basic_string::operator+=(_CharT)): Likewise.
* include/debug/unordered_map (unordered_map(unordered_map&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(unordered_map::operator=(initializer_list<>), unordered_map::merge):
Remove _M_base() calls.
(unordered_multimap(unordered_multimap&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(unordered_multimap::operator=(initializer_list<>), unordered_multimap::merge):
Remove _M_base() calls.
* include/debug/unordered_set (unordered_set(unordered_set&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(unordered_set::operator=(initializer_list<>), unordered_set::merge):
Remove _M_base() calls.
(unordered_multiset(unordered_multiset&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(unordered_multiset::operator=(initializer_list<>), unordered_multiset::merge):
Remove _M_base() calls.
* include/debug/vector (vector(vector&&, const allocator_type&)):
Remove _M_safe() and _M_base() calls.
(vector::operator=(initializer_list<>)): Remove _M_base() calls.
(vector::operator[](size_type)): Likewise.
deque&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
- return _M_base()[__n];
+ return _Base::operator[](__n);
}
_GLIBCXX_NODISCARD
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
- return _M_base()[__n];
+ return _Base::operator[](__n);
}
using _Base::at;
noexcept(
std::is_nothrow_constructible<_Base,
_Base, const allocator_type&>::value )
- : _Safe(std::move(__list._M_safe()), __al),
- _Base(std::move(__list._M_base()), __al)
+ : _Safe(std::move(__list), __al),
+ _Base(std::move(__list), __al)
{ }
explicit
forward_list&
operator=(std::initializer_list<_Tp> __il)
{
- _M_base() = __il;
+ _Base::operator=(__il);
this->_M_invalidate_all();
return *this;
}
return __it != __list._M_base().cbefore_begin()
&& __it != __list._M_base().end();
});
- _Base::splice_after(__pos.base(), std::move(__list._M_base()));
+ _Base::splice_after(__pos.base(), std::move(__list));
}
void
_Base_const_iterator __next = std::next(__i.base());
this->_M_transfer_from_if(__list, [__next](_Base_const_iterator __it)
{ return __it == __next; });
- _Base::splice_after(__pos.base(), std::move(__list._M_base()),
- __i.base());
+ _Base::splice_after(__pos.base(), std::move(__list), __i.base());
}
void
{ return __it == __tmp; });
}
- _Base::splice_after(__pos.base(), std::move(__list._M_base()),
+ _Base::splice_after(__pos.base(), std::move(__list),
__before.base(), __last.base());
}
this->_M_invalidate_if([__next](_Base_const_iterator __it)
{ return __it == __next; });
__to_destroy.splice_after(__to_destroy.cbefore_begin(),
- _M_base(), __old);
+ *this, __old);
__x = __old;
_GLIBCXX20_ONLY( __removed++ );
}
this->_M_invalidate_if([__x](_Base_const_iterator __it)
{ return __it == __x; });
__to_destroy.splice_after(__to_destroy.cbefore_begin(),
- _M_base(), __old);
+ *this, __old);
__x = __old;
_GLIBCXX20_ONLY( __removed++ );
}
this->_M_invalidate_if([__next](_Base_const_iterator __it)
{ return __it == __next; });
__to_destroy.splice_after(__to_destroy.cbefore_begin(),
- _M_base(), __first);
+ *this, __first);
__next = __first;
_GLIBCXX20_ONLY( __removed++ );
}
return __it != __list._M_base().cbefore_begin()
&& __it != __list._M_base().cend();
});
- _Base::merge(std::move(__list._M_base()));
+ _Base::merge(std::move(__list));
}
}
return __it != __list._M_base().cbefore_begin()
&& __it != __list._M_base().cend();
});
- _Base::merge(std::move(__list._M_base()), __comp);
+ _Base::merge(std::move(__list), __comp);
}
}
noexcept(
std::is_nothrow_constructible<_Base,
_Base, const allocator_type&>::value )
- : _Safe(std::move(__x._M_safe()), __a),
- _Base(std::move(__x._M_base()), __a) { }
+ : _Safe(std::move(__x), __a),
+ _Base(std::move(__x), __a) { }
#endif
explicit
operator=(initializer_list<value_type> __l)
{
this->_M_invalidate_all();
- _M_base() = __l;
+ _Base::operator=(__l);
return *this;
}
_M_message(__gnu_debug::__msg_self_splice)
._M_sequence(*this, "this"));
this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
- _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()));
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x));
}
#if __cplusplus >= 201103L
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 250. splicing invalidates iterators
this->_M_transfer_from_if(__x, _Equal(__i.base()));
- _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x),
__i.base());
}
this->_M_transfer_from_if(__x, _Equal(__tmp));
}
- _Base::splice(__position.base(), _GLIBCXX_MOVE(__x._M_base()),
+ _Base::splice(__position.base(), _GLIBCXX_MOVE(__x),
__first.base(), __last.base());
}
// 526. Is it undefined if a function in the standard changes
// in parameters?
this->_M_invalidate_if(_Equal(__first));
- __to_destroy.splice(__to_destroy.begin(), _M_base(), __first);
+ __to_destroy.splice(__to_destroy.begin(), *this, __first);
#if !_GLIBCXX_USE_CXX11_ABI
_GLIBCXX20_ONLY( __removed++ );
#endif
if (__pred(*__x))
{
this->_M_invalidate_if(_Equal(__x));
- __to_destroy.splice(__to_destroy.begin(), _M_base(), __x);
+ __to_destroy.splice(__to_destroy.begin(), *this, __x);
#if !_GLIBCXX_USE_CXX11_ABI
_GLIBCXX20_ONLY( __removed++ );
#endif
if (*__first == *__next)
{
this->_M_invalidate_if(_Equal(__next));
- __to_destroy.splice(__to_destroy.begin(), _M_base(), __next);
+ __to_destroy.splice(__to_destroy.begin(), *this, __next);
__next = __first;
#if !_GLIBCXX_USE_CXX11_ABI
_GLIBCXX20_ONLY( __removed++ );
if (__binary_pred(*__first, *__next))
{
this->_M_invalidate_if(_Equal(__next));
- __to_destroy.splice(__to_destroy.begin(), _M_base(), __next);
+ __to_destroy.splice(__to_destroy.begin(), *this, __next);
__next = __first;
#if !_GLIBCXX_USE_CXX11_ABI
_GLIBCXX20_ONLY( __removed++ );
__glibcxx_check_sorted(_Base::begin(), _Base::end());
__glibcxx_check_sorted(__x.begin().base(), __x.end().base());
this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
- _Base::merge(_GLIBCXX_MOVE(__x._M_base()));
+ _Base::merge(_GLIBCXX_MOVE(__x));
}
}
__glibcxx_check_sorted_pred(__x.begin().base(), __x.end().base(),
__comp);
this->_M_transfer_from_if(__x, _Not_equal(__x._M_base().end()));
- _Base::merge(_GLIBCXX_MOVE(__x._M_base()), __comp);
+ _Base::merge(_GLIBCXX_MOVE(__x), __comp);
}
}
: _Base(__m, __a) { }
map(map&& __m, const __type_identity_t<allocator_type>& __a)
- noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) )
- : _Safe(std::move(__m._M_safe()), __a),
- _Base(std::move(__m._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__m), __a)) )
+ : _Safe(std::move(__m), __a),
+ _Base(std::move(__m), __a) { }
map(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
map&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
: _Base(__m, __a) { }
multimap(multimap&& __m, const __type_identity_t<allocator_type>& __a)
- noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) )
- : _Safe(std::move(__m._M_safe()), __a),
- _Base(std::move(__m._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__m), __a)) )
+ : _Safe(std::move(__m), __a),
+ _Base(std::move(__m), __a) { }
multimap(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
multimap&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
: _Base(__m, __a) { }
multiset(multiset&& __m, const __type_identity_t<allocator_type>& __a)
- noexcept( noexcept(_Base(std::move(__m._M_base()), __a)) )
- : _Safe(std::move(__m._M_safe()), __a),
- _Base(std::move(__m._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__m), __a)) )
+ : _Safe(std::move(__m), __a),
+ _Base(std::move(__m), __a) { }
multiset(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a)
multiset&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
{ return *static_cast<_SafeContainer*>(this); }
protected:
- _Safe_container&
- _M_safe() _GLIBCXX_NOEXCEPT
- { return *this; }
-
#if __cplusplus >= 201103L
_Safe_container() = default;
_Safe_container(const _Safe_container&) = default;
: _Base(__x, __a) { }
set(set&& __x, const __type_identity_t<allocator_type>& __a)
- noexcept( noexcept(_Base(std::move(__x._M_base()), __a)) )
- : _Safe(std::move(__x._M_safe()), __a),
- _Base(std::move(__x._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__x), __a)) )
+ : _Safe(std::move(__x), __a),
+ _Base(std::move(__x), __a) { }
set(initializer_list<value_type> __l, const allocator_type& __a)
: _Base(__l, __a) { }
set&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
basic_string(basic_string&& __s, const _Allocator& __a)
noexcept(
std::is_nothrow_constructible<_Base, _Base, const _Allocator&>::value )
- : _Safe(std::move(__s._M_safe()), __a),
- _Base(std::move(__s._M_base()), __a)
+ : _Safe(std::move(__s), __a),
+ _Base(std::move(__s), __a)
{ }
~basic_string() = default;
operator=(const _CharT* __s)
{
__glibcxx_check_string(__s);
- _M_base() = __s;
+ _Base::operator=(__s);
this->_M_invalidate_all();
return *this;
}
basic_string&
operator=(_CharT __c)
{
- _M_base() = __c;
+ _Base::operator=(__c);
this->_M_invalidate_all();
return *this;
}
basic_string&
operator=(std::initializer_list<_CharT> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
._M_sequence(*this, "this")
._M_integer(__pos, "__pos")
._M_integer(this->size(), "size"));
- return _M_base()[__pos];
+ return _Base::operator[](__pos);
}
reference
._M_integer(__pos, "__pos")
._M_integer(this->size(), "size"));
#endif
- return _M_base()[__pos];
+ return _Base::operator[](__pos);
}
using _Base::at;
basic_string&
operator+=(const basic_string& __str)
{
- _M_base() += __str;
+ _Base::operator+=(__str);
this->_M_invalidate_all();
return *this;
}
operator+=(const _CharT* __s)
{
__glibcxx_check_string(__s);
- _M_base() += __s;
+ _Base::operator+=(__s);
this->_M_invalidate_all();
return *this;
}
basic_string&
operator+=(_CharT __c)
{
- _M_base() += __c;
+ _Base::operator+=(__c);
this->_M_invalidate_all();
return *this;
}
basic_string&
operator+=(std::initializer_list<_CharT> __l)
{
- _M_base() += __l;
+ _Base::operator+=(__l);
this->_M_invalidate_all();
return *this;
}
unordered_map(unordered_map&& __umap,
const allocator_type& __a)
- noexcept( noexcept(_Base(std::move(__umap._M_base()), __a)) )
- : _Safe(std::move(__umap._M_safe()), __a),
- _Base(std::move(__umap._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__umap), __a)) )
+ : _Safe(std::move(__umap), __a),
+ _Base(std::move(__umap), __a) { }
unordered_map(initializer_list<value_type> __l,
size_type __n = 0,
unordered_map&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
{
auto __guard
= _Safe::_S_uc_guard(std::__detail::_Select1st{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
{
auto __guard
= _Safe::_S_umc_guard(std::__detail::_Select1st{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
unordered_multimap(unordered_multimap&& __umap,
const allocator_type& __a)
- noexcept( noexcept(_Base(std::move(__umap._M_base()), __a)) )
- : _Safe(std::move(__umap._M_safe()), __a),
- _Base(std::move(__umap._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__umap), __a)) )
+ : _Safe(std::move(__umap), __a),
+ _Base(std::move(__umap), __a) { }
unordered_multimap(initializer_list<value_type> __l,
size_type __n = 0,
unordered_multimap&
operator=(initializer_list<value_type> __l)
{
- this->_M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
{
auto __guard
= _Safe::_S_umc_guard(std::__detail::_Select1st{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
{
auto __guard
= _Safe::_S_uc_guard(std::__detail::_Select1st{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
unordered_set(unordered_set&& __uset,
const allocator_type& __a)
- noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) )
- : _Safe(std::move(__uset._M_safe()), __a),
- _Base(std::move(__uset._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__uset), __a)) )
+ : _Safe(std::move(__uset), __a),
+ _Base(std::move(__uset), __a) { }
unordered_set(initializer_list<value_type> __l,
size_type __n = 0,
unordered_set&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
{
auto __guard
= _Safe::_S_uc_guard(std::__detail::_Identity{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
{
auto __guard
= _Safe::_S_umc_guard(std::__detail::_Identity{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
unordered_multiset(unordered_multiset&& __uset,
const allocator_type& __a)
- noexcept( noexcept(_Base(std::move(__uset._M_base()), __a)) )
- : _Safe(std::move(__uset._M_safe()), __a),
- _Base(std::move(__uset._M_base()), __a) { }
+ noexcept( noexcept(_Base(std::move(__uset), __a)) )
+ : _Safe(std::move(__uset), __a),
+ _Base(std::move(__uset), __a) { }
unordered_multiset(initializer_list<value_type> __l,
size_type __n = 0,
unordered_multiset&
operator=(initializer_list<value_type> __l)
{
- this->_M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
return *this;
}
{
auto __guard
= _Safe::_S_umc_guard(std::__detail::_Identity{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
{
auto __guard
= _Safe::_S_uc_guard(std::__detail::_Identity{}, __source);
- _Base::merge(__source._M_base());
+ _Base::merge(__source);
}
template<typename _H2, typename _P2>
noexcept(
std::is_nothrow_constructible<_Base,
_Base, const allocator_type&>::value )
- : _Safe(std::move(__x._M_safe()), __a),
- _Base(std::move(__x._M_base()), __a),
+ : _Safe(std::move(__x), __a),
+ _Base(std::move(__x), __a),
_Safe_vector(std::move(__x)) { }
vector(initializer_list<value_type> __l,
vector&
operator=(initializer_list<value_type> __l)
{
- _M_base() = __l;
+ _Base::operator=(__l);
this->_M_invalidate_all();
this->_M_update_guaranteed_capacity();
return *this;
operator[](size_type __n) _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
- return _M_base()[__n];
+ return _Base::operator[](__n);
}
_GLIBCXX_NODISCARD
operator[](size_type __n) const _GLIBCXX_NOEXCEPT
{
__glibcxx_check_subscript(__n);
- return _M_base()[__n];
+ return _Base::operator[](__n);
}
using _Base::at;