From 3d05640bfb1e9681c4e1cad0c56b3917bbaeae44 Mon Sep 17 00:00:00 2001 From: morzhovets Date: Sat, 9 Nov 2024 23:51:49 +0400 Subject: [PATCH] Update deduction guides --- include/momo/stdish/unordered_multimap.h | 68 +++++++++++-------- .../unord.multimap.cnstr/deduct.pass.cpp | 6 -- .../deduct_const.pass.cpp | 4 -- 3 files changed, 41 insertions(+), 37 deletions(-) diff --git a/include/momo/stdish/unordered_multimap.h b/include/momo/stdish/unordered_multimap.h index cb4191c9..c1a3de10 100644 --- a/include/momo/stdish/unordered_multimap.h +++ b/include/momo/stdish/unordered_multimap.h @@ -83,7 +83,7 @@ class unordered_multimap typedef size_t size_type; typedef ptrdiff_t difference_type; - typedef std::pair value_type; + typedef momo::internal::Identity> value_type; typedef momo::internal::HashDerivedIterator iterator; @@ -840,78 +840,92 @@ class unordered_multimap_open : public unordered_multimap::value_type::first_type>, \ - typename Mapped = typename std::iterator_traits::value_type::second_type> \ + typename Value = typename std::iterator_traits::value_type, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t> \ unordered_multimap(Iterator, Iterator) \ -> unordered_multimap; \ template::value_type::first_type>, \ - typename Mapped = typename std::iterator_traits::value_type::second_type, \ + typename Value = typename std::iterator_traits::value_type, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval().allocate(size_t{}))> \ unordered_multimap(Iterator, Iterator, size_t, Allocator = Allocator()) \ -> unordered_multimap, std::equal_to, Allocator>; \ template::value_type::first_type>, \ - typename Mapped = typename std::iterator_traits::value_type::second_type, \ + typename Value = typename std::iterator_traits::value_type, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ typename = decltype(std::declval().allocate(size_t{}))> \ unordered_multimap(Iterator, Iterator, size_t, HashFunc, Allocator = Allocator()) \ -> unordered_multimap, Allocator>; \ template::value_type::first_type>, \ - typename Mapped = typename std::iterator_traits::value_type::second_type, \ + typename Value = typename std::iterator_traits::value_type, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ - typename = decltype(std::declval()(std::declval(), std::declval()))> \ + typename = decltype(std::declval()(std::declval(), std::declval())), \ + typename = decltype(std::declval().allocate(size_t{}))> \ unordered_multimap(Iterator, Iterator, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \ -> unordered_multimap; \ -template \ -unordered_multimap(std::initializer_list>) \ +template> \ +unordered_multimap(std::initializer_list>) \ -> unordered_multimap; \ -template, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval().allocate(size_t{}))> \ -unordered_multimap(std::initializer_list>, size_t, Allocator = Allocator()) \ +unordered_multimap(std::initializer_list>, size_t, Allocator = Allocator()) \ -> unordered_multimap, std::equal_to, Allocator>; \ -template, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ typename = decltype(std::declval().allocate(size_t{}))> \ -unordered_multimap(std::initializer_list>, size_t, HashFunc, Allocator = Allocator()) \ +unordered_multimap(std::initializer_list>, size_t, HashFunc, Allocator = Allocator()) \ -> unordered_multimap, Allocator>; \ -template, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ - typename = decltype(std::declval()(std::declval(), std::declval()))> \ -unordered_multimap(std::initializer_list>, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \ + typename = decltype(std::declval()(std::declval(), std::declval())), \ + typename = decltype(std::declval().allocate(size_t{}))> \ +unordered_multimap(std::initializer_list>, size_t, HashFunc, EqualFunc, Allocator = Allocator()) \ -> unordered_multimap; #define MOMO_DECLARE_DEDUCTION_GUIDES_RANGES(unordered_multimap) \ template::first_type>, \ - typename Mapped = typename std::ranges::range_value_t::second_type> \ + typename Value = std::ranges::range_value_t, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t> \ unordered_multimap(std::from_range_t, Range&&) \ -> unordered_multimap; \ template::first_type>, \ - typename Mapped = typename std::ranges::range_value_t::second_type, \ + typename Value = std::ranges::range_value_t, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval().allocate(size_t{}))> \ unordered_multimap(std::from_range_t, Range&&, size_t, Allocator = Allocator()) \ -> unordered_multimap, std::equal_to, Allocator>; \ template::first_type>, \ - typename Mapped = typename std::ranges::range_value_t::second_type, \ + typename Value = std::ranges::range_value_t, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ typename = decltype(std::declval().allocate(size_t{}))> \ unordered_multimap(std::from_range_t, Range&&, size_t, HashFunc, Allocator = Allocator()) \ -> unordered_multimap, Allocator>; \ template::first_type>, \ - typename Mapped = typename std::ranges::range_value_t::second_type, \ + typename Value = std::ranges::range_value_t, \ + typename Key = std::decay_t, \ + typename Mapped = std::decay_t, \ typename Allocator = std::allocator>, \ typename = decltype(std::declval()(std::declval())), \ typename = decltype(std::declval().allocate(size_t{})), \ diff --git a/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct.pass.cpp b/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct.pass.cpp index df019413..41af96fa 100644 --- a/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct.pass.cpp +++ b/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct.pass.cpp @@ -217,18 +217,14 @@ int main(int, char**) assert(m.get_allocator().get_id() == 48); } -#if !defined(TEST_GCC) { // Examples from LWG3025 momo::stdish::unordered_multimap m{std::pair{1, 1}, {2, 2}, {3, 3}}; ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap); -#ifdef LIBCPP_HAS_BAD_NEWS_FOR_MOMO momo::stdish::unordered_multimap m2{m.begin(), m.end()}; ASSERT_SAME_TYPE(decltype(m2), momo::stdish::unordered_multimap); -#endif } -#endif { // Examples from LWG3531 @@ -292,10 +288,8 @@ int main(int, char**) } #endif -#if MOMO_VERSION_MAJOR > 3 //UnorderedContainerDeductionGuidesSfinaeAway>(); UnorderedContainerDeductionGuidesSfinaeAway>(); -#endif return 0; } diff --git a/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct_const.pass.cpp b/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct_const.pass.cpp index 894d4b54..471aaddc 100644 --- a/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct_const.pass.cpp +++ b/test/sources/libcxx/unord.multimap/unord.multimap.cnstr/deduct_const.pass.cpp @@ -114,7 +114,6 @@ int main(int, char**) assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } -#if MOMO_VERSION_MAJOR > 3 { momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash()); ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap>); @@ -126,7 +125,6 @@ int main(int, char**) ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap, std::equal_to<>>); assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); } -#endif { momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, std::hash(), std::equal_to<>(), test_allocator(0, 44)); @@ -151,7 +149,6 @@ int main(int, char**) assert(m.get_allocator().get_id() == 46); } -#if MOMO_VERSION_MAJOR > 3 { momo::stdish::unordered_multimap m({ PC{1,1L}, PC{2,2L}, PC{1,1L}, PC{INT_MAX,1L}, PC{3,1L} }, 42, test_allocator(0, 47)); ASSERT_SAME_TYPE(decltype(m), momo::stdish::unordered_multimap, std::equal_to, test_allocator>); @@ -165,7 +162,6 @@ int main(int, char**) assert(std::is_permutation(m.begin(), m.end(), std::begin(expected_m), std::end(expected_m))); assert(m.get_allocator().get_id() == 48); } -#endif return 0; }