From 1f6ea96860f448ba4cc5bf1e7570b6181611328b Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 16 May 2019 15:18:45 +0100 Subject: [PATCH] Change EBO accessors from static to non-static member functions * include/bits/hashtable_policy.h (_Hashtable_ebo_helper::_S_get): Replace with _M_get non-static member function. (_Hashtable_ebo_helper::_S_cget): Replace with _M_cget non-static member function. (_Hash_code_base, _Local_iterator_base, _Hashtable_base): (_Hashtable_alloc): Adjust to use non-static members of EBO helper. From-SVN: r271290 --- libstdc++-v3/ChangeLog | 7 +++ libstdc++-v3/include/bits/hashtable_policy.h | 66 +++++++++----------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index acb6b176695..bb947cca088 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,12 @@ 2019-05-16 Jonathan Wakely + * include/bits/hashtable_policy.h (_Hashtable_ebo_helper::_S_get): + Replace with _M_get non-static member function. + (_Hashtable_ebo_helper::_S_cget): Replace with _M_cget non-static + member function. + (_Hash_code_base, _Local_iterator_base, _Hashtable_base): + (_Hashtable_alloc): Adjust to use non-static members of EBO helper. + * include/bits/hashtable_policy.h (_Hash_code_base::_M_swap): Use _S_get accessors for members in EBO helpers. (_Hash_code_base::_M_extract(), _Hash_code_base::_M_ranged_hash()) diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index b417a7d442c..f7db7628c69 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -1112,13 +1112,8 @@ namespace __detail : _Tp(std::forward<_OtherTp>(__tp)) { } - static const _Tp& - _S_cget(const _Hashtable_ebo_helper& __eboh) - { return static_cast(__eboh); } - - static _Tp& - _S_get(_Hashtable_ebo_helper& __eboh) - { return static_cast<_Tp&>(__eboh); } + const _Tp& _M_cget() const { return static_cast(*this); } + _Tp& _M_get() { return static_cast<_Tp&>(*this); } }; /// Specialization not using EBO. @@ -1132,13 +1127,8 @@ namespace __detail : _M_tp(std::forward<_OtherTp>(__tp)) { } - static const _Tp& - _S_cget(const _Hashtable_ebo_helper& __eboh) - { return __eboh._M_tp; } - - static _Tp& - _S_get(_Hashtable_ebo_helper& __eboh) - { return __eboh._M_tp; } + const _Tp& _M_cget() const { return _M_tp; } + _Tp& _M_get() { return _M_tp; } private: _Tp _M_tp; @@ -1229,16 +1219,16 @@ namespace __detail void _M_swap(_Hash_code_base& __x) { - std::swap(__ebo_extract_key::_S_get(*this), - __ebo_extract_key::_S_get(__x)); - std::swap(__ebo_hash::_S_get(*this), __ebo_hash::_S_get(__x)); + std::swap(__ebo_extract_key::_M_get(), + __x.__ebo_extract_key::_M_get()); + std::swap(__ebo_hash::_M_get(), __x.__ebo_hash::_M_get()); } const _ExtractKey& - _M_extract() const { return __ebo_extract_key::_S_cget(*this); } + _M_extract() const { return __ebo_extract_key::_M_cget(); } const _Hash& - _M_ranged_hash() const { return __ebo_hash::_S_cget(*this); } + _M_ranged_hash() const { return __ebo_hash::_M_cget(); } }; // No specialization for ranged hash function while caching hash codes. @@ -1317,20 +1307,20 @@ namespace __detail void _M_swap(_Hash_code_base& __x) { - std::swap(__ebo_extract_key::_S_get(*this), - __ebo_extract_key::_S_get(__x)); - std::swap(__ebo_h1::_S_get(*this), __ebo_h1::_S_get(__x)); - std::swap(__ebo_h2::_S_get(*this), __ebo_h2::_S_get(__x)); + std::swap(__ebo_extract_key::_M_get(), + __x.__ebo_extract_key::_M_get()); + std::swap(__ebo_h1::_M_get(), __x.__ebo_h1::_M_get()); + std::swap(__ebo_h2::_M_get(), __x.__ebo_h2::_M_get()); } const _ExtractKey& - _M_extract() const { return __ebo_extract_key::_S_cget(*this); } + _M_extract() const { return __ebo_extract_key::_M_cget(); } const _H1& - _M_h1() const { return __ebo_h1::_S_cget(*this); } + _M_h1() const { return __ebo_h1::_M_cget(); } const _H2& - _M_h2() const { return __ebo_h2::_S_cget(*this); } + _M_h2() const { return __ebo_h2::_M_cget(); } }; /// Specialization: hash function and range-hashing function, @@ -1397,20 +1387,20 @@ namespace __detail void _M_swap(_Hash_code_base& __x) { - std::swap(__ebo_extract_key::_S_get(*this), - __ebo_extract_key::_S_get(__x)); - std::swap(__ebo_h1::_S_get(*this), __ebo_h1::_S_get(__x)); - std::swap(__ebo_h2::_S_get(*this), __ebo_h2::_S_get(__x)); + std::swap(__ebo_extract_key::_M_get(), + __x.__ebo_extract_key::_M_get()); + std::swap(__ebo_h1::_M_get(), __x.__ebo_h1::_M_get()); + std::swap(__ebo_h2::_M_get(), __x.__ebo_h2::_M_get()); } const _ExtractKey& - _M_extract() const { return __ebo_extract_key::_S_cget(*this); } + _M_extract() const { return __ebo_extract_key::_M_cget(); } const _H1& - _M_h1() const { return __ebo_h1::_S_cget(*this); } + _M_h1() const { return __ebo_h1::_M_cget(); } const _H2& - _M_h2() const { return __ebo_h2::_S_cget(*this); } + _M_h2() const { return __ebo_h2::_M_cget(); } }; /** @@ -1471,7 +1461,7 @@ namespace __detail if (_M_cur) { std::size_t __bkt - = __base_type::_S_get(*this)(_M_cur->_M_hash_code, + = __base_type::_M_get()(_M_cur->_M_hash_code, _M_bucket_count); if (__bkt != _M_bucket) _M_cur = nullptr; @@ -1819,11 +1809,11 @@ namespace __detail _M_swap(_Hashtable_base& __x) { __hash_code_base::_M_swap(__x); - std::swap(_EqualEBO::_S_get(*this), _EqualEBO::_S_get(__x)); + std::swap(_EqualEBO::_M_get(), __x._EqualEBO::_M_get()); } const _Equal& - _M_eq() const { return _EqualEBO::_S_cget(*this); } + _M_eq() const { return _EqualEBO::_M_cget(); } }; /** @@ -2021,11 +2011,11 @@ namespace __detail __node_alloc_type& _M_node_allocator() - { return __ebo_node_alloc::_S_get(*this); } + { return __ebo_node_alloc::_M_get(); } const __node_alloc_type& _M_node_allocator() const - { return __ebo_node_alloc::_S_cget(*this); } + { return __ebo_node_alloc::_M_cget(); } template __node_type* -- 2.30.2