From 957f5feacf2f4c7916e0137ad95d2d9559e06fa4 Mon Sep 17 00:00:00 2001 From: Ville Voutilainen Date: Thu, 26 Oct 2017 19:42:31 +0300 Subject: [PATCH] Deduction guides for associative containers, debug mode deduction guide fixes. * include/bits/stl_iterator.h (__iter_key_t) (__iter_val_t, __iter_to_alloc_t): New. * include/bits/stl_map.h: Add deduction guides. * include/bits/stl_multimap.h: Likewise. * include/bits/stl_multiset.h: Likewise. * include/bits/stl_set.h: Likewise. * include/bits/unordered_map.h: Likewise. * include/bits/unordered_set.h: Likewise. * include/debug/deque: Likewise. * include/debug/forward_list: Likewise. * include/debug/list: Likewise. * include/debug/map.h: Likewise. * include/debug/multimap.h: Likewise. * include/debug/multiset.h: Likewise. * include/debug/set.h: Likewise. * include/debug/unordered_map: Likewise. * include/debug/unordered_set: Likewise. * include/debug/vector: Likewise. * testsuite/23_containers/map/cons/deduction.cc: New. * testsuite/23_containers/multimap/cons/deduction.cc: Likewise. * testsuite/23_containers/multiset/cons/deduction.cc: Likewise. * testsuite/23_containers/set/cons/deduction.cc: Likewise. * testsuite/23_containers/unordered_map/cons/deduction.cc: Likewise. * testsuite/23_containers/unordered_multimap/cons/deduction.cc: Likewise. * testsuite/23_containers/unordered_multiset/cons/deduction.cc: Likewise. * testsuite/23_containers/unordered_set/cons/deduction.cc: Likewise. From-SVN: r254113 --- libstdc++-v3/ChangeLog | 33 ++++ libstdc++-v3/include/bits/stl_iterator.h | 21 +++ libstdc++-v3/include/bits/stl_map.h | 34 ++++ libstdc++-v3/include/bits/stl_multimap.h | 33 ++++ libstdc++-v3/include/bits/stl_multiset.h | 38 +++++ libstdc++-v3/include/bits/stl_set.h | 35 ++++ libstdc++-v3/include/bits/unordered_map.h | 152 ++++++++++++++++++ libstdc++-v3/include/bits/unordered_set.h | 133 +++++++++++++++ libstdc++-v3/include/debug/deque | 10 ++ libstdc++-v3/include/debug/forward_list | 10 ++ libstdc++-v3/include/debug/list | 10 ++ libstdc++-v3/include/debug/map.h | 33 ++++ libstdc++-v3/include/debug/multimap.h | 33 ++++ libstdc++-v3/include/debug/multiset.h | 37 +++++ libstdc++-v3/include/debug/set.h | 36 +++++ libstdc++-v3/include/debug/unordered_map | 152 ++++++++++++++++++ libstdc++-v3/include/debug/unordered_set | 132 +++++++++++++++ libstdc++-v3/include/debug/vector | 10 ++ .../23_containers/map/cons/deduction.cc | 68 ++++++++ .../23_containers/multimap/cons/deduction.cc | 68 ++++++++ .../23_containers/multiset/cons/deduction.cc | 68 ++++++++ .../23_containers/set/cons/deduction.cc | 68 ++++++++ .../unordered_map/cons/deduction.cc | 77 +++++++++ .../unordered_multimap/cons/deduction.cc | 77 +++++++++ .../unordered_multiset/cons/deduction.cc | 78 +++++++++ .../unordered_set/cons/deduction.cc | 78 +++++++++ 26 files changed, 1524 insertions(+) create mode 100644 libstdc++-v3/testsuite/23_containers/map/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multimap/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_map/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/deduction.cc create mode 100644 libstdc++-v3/testsuite/23_containers/unordered_set/cons/deduction.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 438b187346f..a4df5b6398c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,36 @@ +2017-10-26 Ville Voutilainen + + Deduction guides for associative containers, debug mode deduction + guide fixes. + * include/bits/stl_iterator.h (__iter_key_t) + (__iter_val_t, __iter_to_alloc_t): New. + * include/bits/stl_map.h: Add deduction guides. + * include/bits/stl_multimap.h: Likewise. + * include/bits/stl_multiset.h: Likewise. + * include/bits/stl_set.h: Likewise. + * include/bits/unordered_map.h: Likewise. + * include/bits/unordered_set.h: Likewise. + * include/debug/deque: Likewise. + * include/debug/forward_list: Likewise. + * include/debug/list: Likewise. + * include/debug/map.h: Likewise. + * include/debug/multimap.h: Likewise. + * include/debug/multiset.h: Likewise. + * include/debug/set.h: Likewise. + * include/debug/unordered_map: Likewise. + * include/debug/unordered_set: Likewise. + * include/debug/vector: Likewise. + * testsuite/23_containers/map/cons/deduction.cc: New. + * testsuite/23_containers/multimap/cons/deduction.cc: Likewise. + * testsuite/23_containers/multiset/cons/deduction.cc: Likewise. + * testsuite/23_containers/set/cons/deduction.cc: Likewise. + * testsuite/23_containers/unordered_map/cons/deduction.cc: Likewise. + * testsuite/23_containers/unordered_multimap/cons/deduction.cc: + Likewise. + * testsuite/23_containers/unordered_multiset/cons/deduction.cc: + Likewise. + * testsuite/23_containers/unordered_set/cons/deduction.cc: Likewise. + 2017-10-25 Jonathan Wakely * doc/xml/manual/status_cxx2017.xml: Update C++17 status, and diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 88667a568c3..74ef0d9bf88 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -1244,6 +1244,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) #endif // C++11 +#if __cpp_deduction_guides >= 201606 + // These helper traits are used for deduction guides + // of associative containers. + template + using __iter_key_t = remove_const_t< + typename iterator_traits<_InputIterator>::value_type::first_type>; + + template + using __iter_val_t = + typename iterator_traits<_InputIterator>::value_type::second_type; + + template + struct pair; + + template + using __iter_to_alloc_t = + pair>, + __iter_val_t<_InputIterator>>; + +#endif + _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index bad6020ef47..8a9e6c9c329 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -1381,6 +1381,40 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const map<_K1, _T1, _C1, _A1>&); }; + +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + map(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<_Key, _Tp, _Compare, _Allocator>; + + template , + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, _Allocator) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + map(initializer_list>, _Allocator) + -> map<_Key, _Tp, less<_Key>, _Allocator>; + +#endif + /** * @brief Map equality comparison. * @param __x A %map. diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index 6f5cb7a47db..1a16bf982e3 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -1047,6 +1047,39 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const multimap<_K1, _T1, _C1, _A1>&); }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + multimap(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<_Key, _Tp, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, _Allocator) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + multimap(initializer_list>, _Allocator) + -> multimap<_Key, _Tp, less<_Key>, _Allocator>; + +#endif + /** * @brief Multimap equality comparison. * @param __x A %multimap. diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 517e77e9372..d34b6758e18 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -881,6 +881,43 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const multiset<_K1, _C1, _A1>&); }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireAllocator<_Allocator>> + multiset(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, _Allocator) + -> multiset::value_type, + less::value_type>, + _Allocator>; + + template> + multiset(initializer_list<_Key>, _Allocator) + -> multiset<_Key, less<_Key>, _Allocator>; + +#endif + /** * @brief Multiset equality comparison. * @param __x A %multiset. @@ -971,6 +1008,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER _S_get_tree(_GLIBCXX_STD_C::multiset<_Val, _Cmp2, _Alloc>& __set) { return __set._M_t; } }; + #endif // C++17 _GLIBCXX_END_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index e804a7cae70..3a7992c4dab 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -898,6 +898,41 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER operator<(const set<_K1, _C1, _A1>&, const set<_K1, _C1, _A1>&); }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireAllocator<_Allocator>> + set(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, _Allocator) + -> set::value_type, + less::value_type>, + _Allocator>; + + template> + set(initializer_list<_Key>, _Allocator) + -> set<_Key, less<_Key>, _Allocator>; + +#endif /** * @brief Set equality comparison. diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h index 2fd4cd54962..385e4bd4df4 100644 --- a/libstdc++-v3/include/bits/unordered_map.h +++ b/libstdc++-v3/include/bits/unordered_map.h @@ -1130,6 +1130,82 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const unordered_map<_Key1, _Tp1, _Hash1, _Pred1, _Alloc1>&); }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + /** * @brief A standard container composed of equivalent keys * (possibly containing multiple of each key value) that associates @@ -1893,6 +1969,82 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _Hash1, _Pred1, _Alloc1>&); }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, _Pred, + _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Hash, + _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Hash, _Allocator) + -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + template inline void swap(unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h index df57915f31a..416dbbcfb96 100644 --- a/libstdc++-v3/include/bits/unordered_set.h +++ b/libstdc++-v3/include/bits/unordered_set.h @@ -805,6 +805,70 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const unordered_set<_Value1, _Hash1, _Pred1, _Alloc1>&); }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, _Allocator) + -> unordered_set::value_type, + hash< + typename iterator_traits<_InputIterator>::value_type>, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, + _Hash, _Allocator) + -> unordered_set::value_type, + _Hash, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Allocator) + -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Hash, _Allocator) + -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + /** * @brief A standard container composed of equivalent keys * (possibly containing multiple of each key value) in which the @@ -1517,6 +1581,75 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER const unordered_multiset<_Value1, _Hash1, _Pred1, _Alloc1>&); }; + +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset::value_type, + hash::value_type>, + equal_to::value_type>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, + _Hash, _Allocator) + -> unordered_multiset::value_type, + _Hash, + equal_to< + typename + iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Hash, _Allocator) + -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + template inline void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index 7e3c193c103..5816b4b1624 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -624,6 +624,16 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + deque(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> deque<_ValT, _Allocator>; +#endif + template inline bool operator==(const deque<_Tp, _Alloc>& __lhs, diff --git a/libstdc++-v3/include/debug/forward_list b/libstdc++-v3/include/debug/forward_list index cd343302b00..20c7ebe4a8f 100644 --- a/libstdc++-v3/include/debug/forward_list +++ b/libstdc++-v3/include/debug/forward_list @@ -772,6 +772,16 @@ namespace __debug _M_base() const noexcept { return *this; } }; +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + forward_list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> forward_list<_ValT, _Allocator>; +#endif + template bool operator==(const forward_list<_Tp, _Alloc>& __lx, diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index a45ece244bd..94d325c6e6a 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -769,6 +769,16 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + list(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> list<_ValT, _Allocator>; +#endif + template inline bool operator==(const list<_Tp, _Alloc>& __lhs, diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index c275979052c..d5a2c9f6e6f 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -667,6 +667,39 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + map(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> map<_Key, _Tp, _Compare, _Allocator>; + + template , + typename = _RequireAllocator<_Allocator>> + map(_InputIterator, _InputIterator, _Allocator) + -> map<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + map(initializer_list>, _Allocator) + -> map<_Key, _Tp, less<_Key>, _Allocator>; + +#endif + template inline bool diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index f971cfa41f0..6c7b2ab4f8d 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -555,6 +555,39 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + multimap(initializer_list>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multimap<_Key, _Tp, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multimap(_InputIterator, _InputIterator, _Allocator) + -> multimap<__iter_key_t<_InputIterator>, __iter_val_t<_InputIterator>, + less<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + multimap(initializer_list>, _Allocator) + -> multimap<_Key, _Tp, less<_Key>, _Allocator>; + +#endif + template inline bool diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index 97c7b843f27..59331b4bc6b 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -542,6 +542,43 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireAllocator<_Allocator>> + multiset(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> multiset<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + multiset(_InputIterator, _InputIterator, _Allocator) + -> multiset::value_type, + less::value_type>, + _Allocator>; + + template> + multiset(initializer_list<_Key>, _Allocator) + -> multiset<_Key, less<_Key>, _Allocator>; + +#endif + template inline bool operator==(const multiset<_Key, _Compare, _Allocator>& __lhs, diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index 07032865bc9..5353cfe87b2 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -560,6 +560,42 @@ namespace __debug _M_base() const _GLIBCXX_NOEXCEPT { return *this; } }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set::value_type, + _Compare, _Allocator>; + + template, + typename _Allocator = allocator<_Key>, + typename = _RequireAllocator<_Allocator>> + set(initializer_list<_Key>, + _Compare = _Compare(), _Allocator = _Allocator()) + -> set<_Key, _Compare, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + set(_InputIterator, _InputIterator, _Allocator) + -> set::value_type, + less::value_type>, + _Allocator>; + + template> + set(initializer_list<_Key>, _Allocator) + -> set<_Key, less<_Key>, _Allocator>; + +#endif + template inline bool operator==(const set<_Key, _Compare, _Allocator>& __lhs, diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 51a55ae21f3..c5734304846 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -616,6 +616,82 @@ namespace __debug } }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + unordered_map(initializer_list>, + typename unordered_map::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_map<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_map(_InputIterator, _InputIterator, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, _Allocator) + -> unordered_map<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_map(initializer_list>, + typename unordered_map::size_type, + _Hash, _Allocator) + -> unordered_map<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + template inline void @@ -1110,6 +1186,82 @@ namespace __debug } }; +#if __cpp_deduction_guides >= 201606 + + template>, + typename _Pred = equal_to<__iter_key_t<_InputIterator>>, + typename _Allocator = allocator<__iter_to_alloc_t<_InputIterator>>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, _Pred, + _Allocator>; + + template, + typename _Pred = equal_to<_Key>, + typename _Allocator = allocator>, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(initializer_list>, + unordered_multimap::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multimap<_Key, _Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, + hash<__iter_key_t<_InputIterator>>, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multimap(_InputIterator, _InputIterator, + unordered_multimap::size_type, _Hash, + _Allocator) + -> unordered_multimap<__iter_key_t<_InputIterator>, + __iter_val_t<_InputIterator>, _Hash, + equal_to<__iter_key_t<_InputIterator>>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, _Allocator) + -> unordered_multimap<_Key, _Tp, hash<_Key>, equal_to<_Key>, _Allocator>; + + template> + unordered_multimap(initializer_list>, + unordered_multimap::size_type, + _Hash, _Allocator) + -> unordered_multimap<_Key, _Tp, _Hash, equal_to<_Key>, _Allocator>; + +#endif + template inline void diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index 923ff2bc4d8..1fe493fe52f 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -530,6 +530,70 @@ namespace __debug } }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireAllocator<_Allocator>> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), _Allocator = _Allocator()) + -> unordered_set<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, _Allocator) + -> unordered_set::value_type, + hash< + typename iterator_traits<_InputIterator>::value_type>, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_set(_InputIterator, _InputIterator, + unordered_set::size_type, + _Hash, _Allocator) + -> unordered_set::value_type, + _Hash, + equal_to< + typename iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Allocator) + -> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template> + unordered_set(initializer_list<_Tp>, + unordered_set::size_type, _Hash, _Allocator) + -> unordered_set<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + template inline void swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, @@ -1012,6 +1076,74 @@ namespace __debug } }; +#if __cpp_deduction_guides >= 201606 + + template::value_type>, + typename _Pred = + equal_to::value_type>, + typename _Allocator = + allocator::value_type>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset::value_type, + _Hash, _Pred, _Allocator>; + + template, + typename _Pred = equal_to<_Tp>, + typename _Allocator = allocator<_Tp>, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type = {}, + _Hash = _Hash(), _Pred = _Pred(), + _Allocator = _Allocator()) + -> unordered_multiset<_Tp, _Hash, _Pred, _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset::value_type, + hash::value_type>, + equal_to::value_type>, + _Allocator>; + + template, + typename = _RequireAllocator<_Allocator>> + unordered_multiset(_InputIterator, _InputIterator, + unordered_multiset::size_type, + _Hash, _Allocator) + -> unordered_multiset::value_type, + _Hash, + equal_to< + typename + iterator_traits<_InputIterator>::value_type>, + _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Allocator) + -> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>; + + template> + unordered_multiset(initializer_list<_Tp>, + unordered_multiset::size_type, _Hash, _Allocator) + -> unordered_multiset<_Tp, _Hash, equal_to<_Tp>, _Allocator>; + +#endif + template inline void swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x, diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index a6d18d94508..c24c2f3d45f 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -757,6 +757,16 @@ namespace __debug _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs))) { __lhs.swap(__rhs); } +#if __cpp_deduction_guides >= 201606 + template::value_type, + typename _Allocator = allocator<_ValT>, + typename = _RequireInputIter<_InputIterator>, + typename = _RequireAllocator<_Allocator>> + vector(_InputIterator, _InputIterator, _Allocator = _Allocator()) + -> vector<_ValT, _Allocator>; +#endif + } // namespace __debug #if __cplusplus >= 201103L diff --git a/libstdc++-v3/testsuite/23_containers/map/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/map/cons/deduction.cc new file mode 100644 index 00000000000..3880cd5e79d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/cons/deduction.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::map{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}), + std::map>); + +static_assert(std::is_same_v< + decltype(std::map{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}}), + std::map>); + +static_assert(std::is_same_v< + decltype(std::map{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + std::less{}, {}}), + std::map>); + +static_assert(std::is_same_v< + decltype(std::map{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + {}}), + std::map>); + +static_assert(std::is_same_v< + decltype(std::map{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + {}, SimpleAllocator>{}}), + std::map, + SimpleAllocator>>>); + +void f() +{ + std::map x; + static_assert(std::is_same_v< + decltype(std::map(x.begin(), x.end())), + std::map>); + + static_assert(std::is_same_v< + decltype(std::map{x.begin(), x.end(), + std::less{}, + std::allocator>{}}), + std::map>); + + static_assert(std::is_same_v< + decltype(std::map{x.begin(), x.end(), + std::less{}, {}}), + std::map>); + + static_assert(std::is_same_v< + decltype(std::map(x.begin(), x.end(), + {})), + std::map>); + + static_assert(std::is_same_v< + decltype(std::map{x.begin(), x.end(), + {}, + std::allocator>{}}), + std::map>); + + static_assert(std::is_same_v< + decltype(std::map{x.begin(), x.end(), + {}, + SimpleAllocator>{}}), + std::map, + SimpleAllocator>>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/multimap/cons/deduction.cc new file mode 100644 index 00000000000..ee48bfda26b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/cons/deduction.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::multimap{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}), + std::multimap>); + +static_assert(std::is_same_v< + decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}}), + std::multimap>); + +static_assert(std::is_same_v< + decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + std::less{}, {}}), + std::multimap>); + +static_assert(std::is_same_v< + decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + {}}), + std::multimap>); + +static_assert(std::is_same_v< + decltype(std::multimap{{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}}, + {}, SimpleAllocator>{}}), + std::multimap, + SimpleAllocator>>>); + +void f() +{ + std::multimap x; + static_assert(std::is_same_v< + decltype(std::multimap(x.begin(), x.end())), + std::multimap>); + + static_assert(std::is_same_v< + decltype(std::multimap{x.begin(), x.end(), + std::less{}, + std::allocator>{}}), + std::multimap>); + + static_assert(std::is_same_v< + decltype(std::multimap{x.begin(), x.end(), + std::less{}, {}}), + std::multimap>); + + static_assert(std::is_same_v< + decltype(std::multimap(x.begin(), x.end(), + {})), + std::multimap>); + + static_assert(std::is_same_v< + decltype(std::multimap{x.begin(), x.end(), + {}, + std::allocator>{}}), + std::multimap>); + + static_assert(std::is_same_v< + decltype(std::multimap{x.begin(), x.end(), + {}, + SimpleAllocator>{}}), + std::multimap, + SimpleAllocator>>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc new file mode 100644 index 00000000000..4ca3f98129a --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/cons/deduction.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::multiset{1, 2, 3}), + std::multiset>); + +static_assert(std::is_same_v< + decltype(std::multiset{1, 2, 3}), + std::multiset>); + +static_assert(std::is_same_v< + decltype(std::multiset{{1, 2, 3}, + std::less{}, {}}), + std::multiset>); + +static_assert(std::is_same_v< + decltype(std::multiset{{1, 2, 3}, + {}}), + std::multiset>); + +static_assert(std::is_same_v< + decltype(std::multiset{{1, 2, 3}, + {}, SimpleAllocator{}}), + std::multiset, + SimpleAllocator>>); + +void f() +{ + std::multiset x; + + static_assert(std::is_same_v< + decltype(std::multiset(x.begin(), x.end())), + std::multiset>); + + static_assert(std::is_same_v< + decltype(std::multiset{x.begin(), x.end(), + std::less{}, + std::allocator{}}), + std::multiset>); + + static_assert(std::is_same_v< + decltype(std::multiset{x.begin(), x.end(), + std::less{}, {}}), + std::multiset>); + + static_assert(std::is_same_v< + decltype(std::multiset(x.begin(), x.end(), + {})), + std::multiset>); + + static_assert(std::is_same_v< + decltype(std::multiset{x.begin(), x.end(), + {}, + std::allocator{}}), + std::multiset>); + + static_assert(std::is_same_v< + decltype(std::multiset{x.begin(), x.end(), + {}, + SimpleAllocator{}}), + std::multiset, SimpleAllocator>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc new file mode 100644 index 00000000000..73d5cfdd227 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/cons/deduction.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::set{1, 2, 3}), + std::set>); + +static_assert(std::is_same_v< + decltype(std::set{1, 2, 3}), + std::set>); + +static_assert(std::is_same_v< + decltype(std::set{{1, 2, 3}, + std::less{}, {}}), + std::set>); + +static_assert(std::is_same_v< + decltype(std::set{{1, 2, 3}, + {}}), + std::set>); + +static_assert(std::is_same_v< + decltype(std::set{{1, 2, 3}, + {}, SimpleAllocator{}}), + std::set, + SimpleAllocator>>); + +void f() +{ + std::set x; + + static_assert(std::is_same_v< + decltype(std::set(x.begin(), x.end())), + std::set>); + + static_assert(std::is_same_v< + decltype(std::set{x.begin(), x.end(), + std::less{}, + std::allocator{}}), + std::set>); + + static_assert(std::is_same_v< + decltype(std::set{x.begin(), x.end(), + std::less{}, {}}), + std::set>); + + static_assert(std::is_same_v< + decltype(std::set(x.begin(), x.end(), + {})), + std::set>); + + static_assert(std::is_same_v< + decltype(std::set{x.begin(), x.end(), + {}, + std::allocator{}}), + std::set>); + + static_assert(std::is_same_v< + decltype(std::set{x.begin(), x.end(), + {}, + SimpleAllocator{}}), + std::set, SimpleAllocator>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/deduction.cc new file mode 100644 index 00000000000..1905b20116b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/cons/deduction.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::unordered_map{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}), + std::unordered_map>); + +static_assert(std::is_same_v< + decltype(std::unordered_map{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}}), + std::unordered_map>); + +static_assert(std::is_same_v< + decltype(std::unordered_map{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}, std::hash{}, {}}), + std::unordered_map>); + +static_assert(std::is_same_v< + decltype(std::unordered_map{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}}), + std::unordered_map>); + +static_assert(std::is_same_v< + decltype(std::unordered_map{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}, {}, {}, + SimpleAllocator>{}}), + std::unordered_map, + std::equal_to, + SimpleAllocator>>>); + + +void f() +{ + std::unordered_map x; + static_assert(std::is_same_v< + decltype(std::unordered_map(x.begin(), x.end())), + std::unordered_map>); + + static_assert(std::is_same_v< + decltype(std::unordered_map{x.begin(), x.end(), + {}, std::hash{}, {}, + std::allocator>{}}), + std::unordered_map>); + + static_assert(std::is_same_v< + decltype(std::unordered_map{x.begin(), x.end(), + {}, std::hash{}, {}}), + std::unordered_map>); + + static_assert(std::is_same_v< + decltype(std::unordered_map(x.begin(), x.end(), + {})), + std::unordered_map>); + + static_assert(std::is_same_v< + decltype(std::unordered_map{x.begin(), x.end(), + {}, {}, {}, + std::allocator>{}}), + std::unordered_map>); + + static_assert(std::is_same_v< + decltype(std::unordered_map{x.begin(), x.end(), + {}, {}, {}, + SimpleAllocator>{}}), + std::unordered_map, + std::equal_to, + SimpleAllocator>>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/deduction.cc new file mode 100644 index 00000000000..db5e32b4ad2 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/cons/deduction.cc @@ -0,0 +1,77 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::unordered_multimap{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}), + std::unordered_multimap>); + +static_assert(std::is_same_v< + decltype(std::unordered_multimap{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}}), + std::unordered_multimap>); + +static_assert(std::is_same_v< + decltype(std::unordered_multimap{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}, std::hash{}, {}}), + std::unordered_multimap>); + +static_assert(std::is_same_v< + decltype(std::unordered_multimap{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}}), + std::unordered_multimap>); + +static_assert(std::is_same_v< + decltype(std::unordered_multimap{{std::pair{1, 2.0}, + {2, 3.0}, {3, 4.0}}, + {}, {}, {}, + SimpleAllocator>{}}), + std::unordered_multimap, + std::equal_to, + SimpleAllocator>>>); + + +void f() +{ + std::unordered_multimap x; + static_assert(std::is_same_v< + decltype(std::unordered_multimap(x.begin(), x.end())), + std::unordered_multimap>); + + static_assert(std::is_same_v< + decltype(std::unordered_multimap{x.begin(), x.end(), + {}, std::hash{}, {}, + std::allocator>{}}), + std::unordered_multimap>); + + static_assert(std::is_same_v< + decltype(std::unordered_multimap{x.begin(), x.end(), + {}, std::hash{}, {}}), + std::unordered_multimap>); + + static_assert(std::is_same_v< + decltype(std::unordered_multimap(x.begin(), x.end(), + {})), + std::unordered_multimap>); + + static_assert(std::is_same_v< + decltype(std::unordered_multimap{x.begin(), x.end(), + {}, {}, {}, + std::allocator>{}}), + std::unordered_multimap>); + + static_assert(std::is_same_v< + decltype(std::unordered_multimap{x.begin(), x.end(), + {}, {}, {}, + SimpleAllocator>{}}), + std::unordered_multimap, + std::equal_to, + SimpleAllocator>>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/deduction.cc new file mode 100644 index 00000000000..352176d1e7d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/cons/deduction.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{1, 2, 3}), + std::unordered_multiset>); + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{1, 2, 3}), + std::unordered_multiset>); + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{{1, 2, 3}, + 0, std::hash{}, {}}), + std::unordered_multiset>); + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{{1, 2, 3}, + {}}), + std::unordered_multiset>); + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{{1, 2, 3}, + {}, {}, {}, std::allocator{}}), + std::unordered_multiset>); + +static_assert(std::is_same_v< + decltype(std::unordered_multiset{{1, 2, 3}, + {}, {}, {}, SimpleAllocator{}}), + std::unordered_multiset, + std::equal_to, + SimpleAllocator>>); + +void f() +{ + std::unordered_multiset x; + + static_assert(std::is_same_v< + decltype(std::unordered_multiset(x.begin(), x.end())), + std::unordered_multiset>); + + static_assert(std::is_same_v< + decltype(std::unordered_multiset{x.begin(), x.end(), + {}, + std::hash{}, + std::equal_to{}, + std::allocator{}}), + std::unordered_multiset>); + + static_assert(std::is_same_v< + decltype(std::unordered_multiset{x.begin(), x.end(), + {}, std::hash{}, {}}), + std::unordered_multiset>); + + static_assert(std::is_same_v< + decltype(std::unordered_multiset(x.begin(), x.end(), + {})), + std::unordered_multiset>); + + static_assert(std::is_same_v< + decltype(std::unordered_multiset{x.begin(), x.end(), + {}, {}, {}, + std::allocator{}}), + std::unordered_multiset>); + + static_assert(std::is_same_v< + decltype(std::unordered_multiset{x.begin(), x.end(), + {}, {}, {}, + SimpleAllocator{}}), + std::unordered_multiset, + std::equal_to, + SimpleAllocator>>); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/cons/deduction.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/deduction.cc new file mode 100644 index 00000000000..c7e1798ef7d --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/cons/deduction.cc @@ -0,0 +1,78 @@ +// { dg-options "-std=gnu++17" } +// { dg-do compile { target c++17 } } + +#include +#include + +using __gnu_test::SimpleAllocator; + +static_assert(std::is_same_v< + decltype(std::unordered_set{1, 2, 3}), + std::unordered_set>); + +static_assert(std::is_same_v< + decltype(std::unordered_set{1, 2, 3}), + std::unordered_set>); + +static_assert(std::is_same_v< + decltype(std::unordered_set{{1, 2, 3}, + 0, std::hash{}, {}}), + std::unordered_set>); + +static_assert(std::is_same_v< + decltype(std::unordered_set{{1, 2, 3}, + {}}), + std::unordered_set>); + +static_assert(std::is_same_v< + decltype(std::unordered_set{{1, 2, 3}, + {}, {}, {}, std::allocator{}}), + std::unordered_set>); + +static_assert(std::is_same_v< + decltype(std::unordered_set{{1, 2, 3}, + {}, {}, {}, SimpleAllocator{}}), + std::unordered_set, + std::equal_to, + SimpleAllocator>>); + +void f() +{ + std::unordered_set x; + + static_assert(std::is_same_v< + decltype(std::unordered_set(x.begin(), x.end())), + std::unordered_set>); + + static_assert(std::is_same_v< + decltype(std::unordered_set{x.begin(), x.end(), + {}, + std::hash{}, + std::equal_to{}, + std::allocator{}}), + std::unordered_set>); + + static_assert(std::is_same_v< + decltype(std::unordered_set{x.begin(), x.end(), + {}, std::hash{}, {}}), + std::unordered_set>); + + static_assert(std::is_same_v< + decltype(std::unordered_set(x.begin(), x.end(), + {})), + std::unordered_set>); + + static_assert(std::is_same_v< + decltype(std::unordered_set{x.begin(), x.end(), + {}, {}, {}, + std::allocator{}}), + std::unordered_set>); + + static_assert(std::is_same_v< + decltype(std::unordered_set{x.begin(), x.end(), + {}, {}, {}, + SimpleAllocator{}}), + std::unordered_set, + std::equal_to, + SimpleAllocator>>); +} -- 2.30.2