From afbaf9361d64f1baf460618481f36fff60c49f35 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 8 Dec 2022 22:15:43 +0200 Subject: [PATCH] Add MixPolicy template parameter to unordered_flat_map and foa::table --- include/boost/unordered/detail/foa.hpp | 10 ++--- .../boost/unordered/unordered_flat_map.hpp | 38 +++++++++---------- .../unordered/unordered_flat_map_fwd.hpp | 24 +++++++----- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index 289ea457..95c51bfd 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -786,7 +786,7 @@ inline unsigned int unchecked_countr_zero(int x) #endif } -template +template class table; /* table_iterator keeps two pointers: @@ -850,7 +850,7 @@ public: private: template friend class table_iterator; - template friend class table; + template friend class table; table_iterator(Group* pg,std::size_t n,const Value* p_): pc{reinterpret_cast(const_cast(pg))+n}, @@ -1112,7 +1112,7 @@ inline void prefetch(const void* p) */ constexpr static float const mlf = 0.875f; -template +template class #if defined(_MSC_VER)&&_MSC_FULL_VER>=190023918 @@ -1132,7 +1132,7 @@ table:empty_value,empty_value,empty_value using mix_policy=typename std::conditional< hash_is_avalanching::value, no_mix, - xmx_mix + MixPolicy >::type; using alloc_traits=boost::allocator_traits; @@ -1491,7 +1491,7 @@ public: } private: - template friend class table; + template friend class table; using arrays_type=table_arrays; struct clear_on_exit diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index ce09af90..7aeccad8 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -32,7 +32,7 @@ namespace boost { #pragma warning(disable : 4714) /* marked as __forceinline not inlined */ #endif - template + template class unordered_flat_map { struct map_types @@ -61,13 +61,13 @@ namespace boost { using table_type = detail::foa::table::type>; + typename map_types::value_type>::type, MixPolicy>; table_type table_; - template - typename unordered_flat_map::size_type friend erase_if( - unordered_flat_map& set, Pred pred); + template + typename unordered_flat_map::size_type friend erase_if( + unordered_flat_map& set, Pred pred); public: using key_type = Key; @@ -387,7 +387,7 @@ namespace boost { template void merge( - unordered_flat_map& + unordered_flat_map& source) { table_.merge(source.table_); @@ -395,7 +395,7 @@ namespace boost { template void merge( - unordered_flat_map&& + unordered_flat_map&& source) { table_.merge(std::move(source.table_)); @@ -579,10 +579,10 @@ namespace boost { key_equal key_eq() const { return table_.key_eq(); } }; - template + template bool operator==( - unordered_flat_map const& lhs, - unordered_flat_map const& rhs) + unordered_flat_map const& lhs, + unordered_flat_map const& rhs) { if (&lhs == &rhs) { return true; @@ -599,27 +599,27 @@ namespace boost { })(); } - template + template bool operator!=( - unordered_flat_map const& lhs, - unordered_flat_map const& rhs) + unordered_flat_map const& lhs, + unordered_flat_map const& rhs) { return !(lhs == rhs); } - template - void swap(unordered_flat_map& lhs, - unordered_flat_map& rhs) + template + void swap(unordered_flat_map& lhs, + unordered_flat_map& rhs) noexcept(noexcept(lhs.swap(rhs))) { lhs.swap(rhs); } - template - typename unordered_flat_map::size_type + typename unordered_flat_map::size_type erase_if( - unordered_flat_map& map, Pred pred) + unordered_flat_map& map, Pred pred) { return erase_if(map.table_, pred); } diff --git a/include/boost/unordered/unordered_flat_map_fwd.hpp b/include/boost/unordered/unordered_flat_map_fwd.hpp index 2c34d0fb..0853d715 100644 --- a/include/boost/unordered/unordered_flat_map_fwd.hpp +++ b/include/boost/unordered/unordered_flat_map_fwd.hpp @@ -18,24 +18,28 @@ namespace boost { namespace unordered { + + namespace detail { namespace foa { struct xmx_mix; } } + template , class KeyEqual = std::equal_to, - class Allocator = std::allocator > > + class Allocator = std::allocator >, + class MixPolicy = detail::foa::xmx_mix > class unordered_flat_map; - template + template bool operator==( - unordered_flat_map const& lhs, - unordered_flat_map const& rhs); + unordered_flat_map const& lhs, + unordered_flat_map const& rhs); - template + template bool operator!=( - unordered_flat_map const& lhs, - unordered_flat_map const& rhs); + unordered_flat_map const& lhs, + unordered_flat_map const& rhs); - template - void swap(unordered_flat_map& lhs, - unordered_flat_map& rhs) + template + void swap(unordered_flat_map& lhs, + unordered_flat_map& rhs) noexcept(noexcept(lhs.swap(rhs))); } // namespace unordered