From 814926ef31e5a1f21dfc2a84a31d0b20488eb6f6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 23 Apr 2017 10:09:18 +0100 Subject: [PATCH] Expand calls to clear implementation --- .../boost/unordered/detail/implementation.hpp | 11 -------- include/boost/unordered/unordered_map.hpp | 16 +++++++++--- include/boost/unordered/unordered_set.hpp | 26 ++++++++++++------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 086bc613..35d03f4b 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -3078,17 +3078,6 @@ struct table : boost::unordered::detail::functions class unordered_map typedef boost::unordered::detail::map types; typedef typename types::value_allocator_traits value_allocator_traits; typedef typename types::table table; + typedef typename table::link_pointer link_pointer; public: typedef typename value_allocator_traits::pointer pointer; @@ -836,6 +837,7 @@ template class unordered_multimap typedef boost::unordered::detail::multimap types; typedef typename types::value_allocator_traits value_allocator_traits; typedef typename types::table table; + typedef typename table::link_pointer link_pointer; public: typedef typename value_allocator_traits::pointer pointer; @@ -1483,7 +1485,7 @@ template unordered_map& unordered_map::operator=( std::initializer_list list) { - table_.clear(); + this->clear(); table_.insert_range(list.begin(), list.end()); return *this; } @@ -1557,7 +1559,10 @@ void unordered_map::swap(unordered_map& other) template void unordered_map::clear() BOOST_NOEXCEPT { - table_.clear(); + if (table_.size_) { + table_.clear_buckets(); + table_.delete_nodes(table_.get_previous_start(), link_pointer()); + } } template @@ -1912,7 +1917,7 @@ template unordered_multimap& unordered_multimap::operator=( std::initializer_list list) { - table_.clear(); + this->clear(); table_.insert_range(list.begin(), list.end()); return *this; } @@ -1987,7 +1992,10 @@ void unordered_multimap::swap(unordered_multimap& other) template void unordered_multimap::clear() BOOST_NOEXCEPT { - table_.clear(); + if (table_.size_) { + table_.clear_buckets(); + table_.delete_nodes(table_.get_previous_start(), link_pointer()); + } } // observers diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index 336a9472..75fde4fa 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -53,6 +53,7 @@ template class unordered_set typedef boost::unordered::detail::set types; typedef typename types::value_allocator_traits value_allocator_traits; typedef typename types::table table; + typedef typename table::link_pointer link_pointer; public: typedef typename value_allocator_traits::pointer pointer; @@ -562,6 +563,7 @@ template class unordered_multiset typedef boost::unordered::detail::multiset types; typedef typename types::value_allocator_traits value_allocator_traits; typedef typename types::table table; + typedef typename table::link_pointer link_pointer; public: typedef typename value_allocator_traits::pointer pointer; @@ -1179,7 +1181,7 @@ template unordered_set& unordered_set::operator=( std::initializer_list list) { - table_.clear(); + this->clear(); table_.insert_range(list.begin(), list.end()); return *this; } @@ -1245,13 +1247,10 @@ void unordered_set::swap(unordered_set& other) template void unordered_set::clear() BOOST_NOEXCEPT { - table_.clear(); -} - -template -void unordered_multiset::clear() BOOST_NOEXCEPT -{ - table_.clear(); + if (table_.size_) { + table_.clear_buckets(); + table_.delete_nodes(table_.get_previous_start(), link_pointer()); + } } // observers @@ -1553,7 +1552,7 @@ template unordered_multiset& unordered_multiset::operator=( std::initializer_list list) { - table_.clear(); + this->clear(); table_.insert_range(list.begin(), list.end()); return *this; } @@ -1617,6 +1616,15 @@ void unordered_multiset::swap(unordered_multiset& other) table_.swap(other.table_); } +template +void unordered_multiset::clear() BOOST_NOEXCEPT +{ + if (table_.size_) { + table_.clear_buckets(); + table_.delete_nodes(table_.get_previous_start(), link_pointer()); + } +} + // observers template