From 5b92827b68be590cd23995dc54de038e7a3642a8 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Mon, 7 Nov 2022 13:44:21 -0800 Subject: [PATCH] Implement deduction guides for unordered_flat_map --- .../boost/unordered/unordered_flat_map.hpp | 104 +++++++++++++++++- 1 file changed, 101 insertions(+), 3 deletions(-) diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index 7ba2ba28..ac723ce9 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -76,9 +76,9 @@ namespace boost { using init_type = typename map_types::init_type; using size_type = std::size_t; using difference_type = std::ptrdiff_t; - using hasher = Hash; - using key_equal = KeyEqual; - using allocator_type = Allocator; + using hasher = typename boost::type_identity::type; + using key_equal = typename boost::type_identity::type; + using allocator_type = typename boost::type_identity::type; using reference = value_type&; using const_reference = value_type const&; using pointer = typename boost::allocator_pointer::type; @@ -628,6 +628,104 @@ namespace boost { #pragma warning(pop) /* C4714 */ #endif +#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES + + namespace detail { + template + using iter_key_t = + typename std::iterator_traits::value_type::first_type; + template + using iter_val_t = + typename std::iterator_traits::value_type::second_type; + template + using iter_to_alloc_t = + typename std::pair const, iter_val_t >; + } // namespace detail + + template >, + class Pred = + std::equal_to >, + class Allocator = std::allocator< + boost::unordered::detail::iter_to_alloc_t >, + class = boost::enable_if_t >, + class = boost::enable_if_t >, + class = boost::enable_if_t >, + class = boost::enable_if_t > > + unordered_flat_map(InputIterator, InputIterator, + std::size_t = boost::unordered::detail::foa::default_bucket_count, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_flat_map, + boost::unordered::detail::iter_val_t, Hash, Pred, + Allocator>; + + template >, + class Pred = std::equal_to >, + class Allocator = std::allocator >, + class = boost::enable_if_t >, + class = boost::enable_if_t >, + class = boost::enable_if_t > > + unordered_flat_map(std::initializer_list >, + std::size_t = boost::unordered::detail::foa::default_bucket_count, + Hash = Hash(), Pred = Pred(), Allocator = Allocator()) + -> unordered_flat_map, T, Hash, Pred, + Allocator>; + + template >, + class = boost::enable_if_t > > + unordered_flat_map(InputIterator, InputIterator, std::size_t, Allocator) + -> unordered_flat_map, + boost::unordered::detail::iter_val_t, + boost::hash >, + std::equal_to >, + Allocator>; + + template >, + class = boost::enable_if_t > > + unordered_flat_map(InputIterator, InputIterator, Allocator) + -> unordered_flat_map, + boost::unordered::detail::iter_val_t, + boost::hash >, + std::equal_to >, + Allocator>; + + template >, + class = boost::enable_if_t >, + class = boost::enable_if_t > > + unordered_flat_map( + InputIterator, InputIterator, std::size_t, Hash, Allocator) + -> unordered_flat_map, + boost::unordered::detail::iter_val_t, Hash, + std::equal_to >, + Allocator>; + + template > > + unordered_flat_map(std::initializer_list >, std::size_t, + Allocator) -> unordered_flat_map, T, + boost::hash >, + std::equal_to >, Allocator>; + + template > > + unordered_flat_map(std::initializer_list >, Allocator) + -> unordered_flat_map, T, + boost::hash >, + std::equal_to >, Allocator>; + + template >, + class = boost::enable_if_t > > + unordered_flat_map(std::initializer_list >, std::size_t, + Hash, Allocator) -> unordered_flat_map, T, + Hash, std::equal_to >, Allocator>; +#endif + } // namespace unordered } // namespace boost