libstdc++: Implement missing allocator-aware constructors for unordered containers.

This patch implements remainder of LWG2713 (after r15-8293-g64f5c854597759)
by adding missing allocator aware version of unordered associative containers
constructors accepting pair of iterators or initializer_list, and corresponding
deduction guides.

libstdc++-v3/ChangeLog:

	* include/bits/unordered_map.h (unordered_map):
	Define constructors accepting:
	(_InputIterator, _InputIterator, const allocator_type&),
	(initializer_list<value_type>, const allocator_type&),
	(unordered_multimap): Likewise.
	* include/debug/unordered_map (unordered_map): Likewise.
	(unordered_multimap): Likewise.
	* include/bits/unordered_set.h (unordered_set):
	Define constructors and deduction guide accepting:
	(_InputIterator, _InputIterator, const allocator_type&),
	(initializer_list<value_type>, const allocator_type&),
	(unordered_multiset): Likewise.
	* include/debug/unordered_set (unordered_set): Likewise.
	(unordered_multiset): Likewise.
	* testsuite/23_containers/unordered_map/cons/66055.cc: New tests.
	* testsuite/23_containers/unordered_map/cons/deduction.cc: New tests.
	* testsuite/23_containers/unordered_multimap/cons/66055.cc: New tests.
	* testsuite/23_containers/unordered_multimap/cons/deduction.cc:	New
	tests.
	* testsuite/23_containers/unordered_multiset/cons/66055.cc: New tests.
	* testsuite/23_containers/unordered_multiset/cons/deduction.cc:	New
	tests.
	* testsuite/23_containers/unordered_set/cons/66055.cc: New tests.
	* testsuite/23_containers/unordered_set/cons/deduction.cc: New tests.

Reviewed-by: Jonathan Wakely <jwakely@redhat.com>
Signed-off-by: Tomasz Kamiński <tkaminsk@redhat.com>
This commit is contained in:
Tomasz Kamiński
2025-03-18 16:10:48 +01:00
parent b0120fa983
commit 1ecd95ea1e
12 changed files with 320 additions and 16 deletions

View File

@@ -251,6 +251,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_map(__n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered containers
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_map(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -271,6 +279,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_map(__l, __n, hasher(), key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered containers
unordered_map(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_map(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n, const hasher& __hf,
const allocator_type& __a)
@@ -1504,6 +1519,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_multimap(__n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered containers
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_multimap(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -1518,6 +1541,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered containers
unordered_multimap(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_multimap(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)

View File

@@ -245,6 +245,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_set(__n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_set(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -259,6 +267,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_set(__first, __last, __n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
unordered_set(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_set(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_set(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
@@ -987,6 +1003,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_set(_InputIterator, _InputIterator, _Allocator)
-> unordered_set<typename iterator_traits<_InputIterator>::value_type,
hash<
typename iterator_traits<_InputIterator>::value_type>,
equal_to<
typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
@@ -1006,6 +1035,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
unordered_set<int>::size_type, _Allocator)
-> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_set(initializer_list<_Tp>, _Allocator)
-> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
typename = _RequireAllocator<_Allocator>>
@@ -1223,6 +1259,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_multiset(__n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_multiset(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -1237,6 +1281,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
: unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
{ }
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
unordered_multiset(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_multiset(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
@@ -1949,6 +2000,19 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator_traits<_InputIterator>::value_type>,
_Allocator>;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multiset(_InputIterator, _InputIterator, _Allocator)
-> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
hash<typename
iterator_traits<_InputIterator>::value_type>,
equal_to<typename
iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
@@ -1970,6 +2034,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
unordered_multiset<int>::size_type, _Allocator)
-> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
// _GLIBCXX_RESOLVE_LIB_DEFECTS
// 2713. More missing allocator-extended constructors for unordered container
template<typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_multiset(initializer_list<_Tp>, _Allocator)
-> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
typename = _RequireAllocator<_Allocator>>

View File

@@ -173,6 +173,12 @@ namespace __debug
: unordered_map(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_map(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_map(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -188,6 +194,11 @@ namespace __debug
: unordered_map(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_map(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_map(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
@@ -1051,6 +1062,12 @@ namespace __debug
: unordered_multimap(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_multimap(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multimap(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -1065,6 +1082,11 @@ namespace __debug
: unordered_multimap(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_multimap(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_multimap(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)

View File

@@ -168,6 +168,12 @@ namespace __debug
: unordered_set(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_set(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_set(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -182,6 +188,11 @@ namespace __debug
: unordered_set(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_set(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_set(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_set(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
@@ -713,6 +724,17 @@ namespace __debug
typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_set(_InputIterator, _InputIterator, _Allocator)
-> unordered_set<typename iterator_traits<_InputIterator>::value_type,
hash<
typename iterator_traits<_InputIterator>::value_type>,
equal_to<
typename iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
@@ -732,6 +754,11 @@ namespace __debug
unordered_set<int>::size_type, _Allocator)
-> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_set(initializer_list<_Tp>, _Allocator)
-> unordered_set<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
typename = _RequireAllocator<_Allocator>>
@@ -876,6 +903,12 @@ namespace __debug
: unordered_multiset(__n, __hf, key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
const allocator_type& __a)
: unordered_multiset(__first, __last, 0, hasher(), key_equal(), __a)
{ }
template<typename _InputIterator>
unordered_multiset(_InputIterator __first, _InputIterator __last,
size_type __n,
@@ -890,6 +923,11 @@ namespace __debug
: unordered_multiset(__first, __last, __n, __hf, key_equal(), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
const allocator_type& __a)
: unordered_multiset(__l, 0, hasher(), key_equal(), __a)
{ }
unordered_multiset(initializer_list<value_type> __l,
size_type __n,
const allocator_type& __a)
@@ -1416,6 +1454,17 @@ namespace __debug
iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireAllocator<_Allocator>>
unordered_multiset(_InputIterator, _InputIterator, _Allocator)
-> unordered_multiset<typename iterator_traits<_InputIterator>::value_type,
hash<typename
iterator_traits<_InputIterator>::value_type>,
equal_to<typename
iterator_traits<_InputIterator>::value_type>,
_Allocator>;
template<typename _InputIterator, typename _Hash, typename _Allocator,
typename = _RequireInputIter<_InputIterator>,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
@@ -1437,6 +1486,11 @@ namespace __debug
unordered_multiset<int>::size_type, _Allocator)
-> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Allocator,
typename = _RequireAllocator<_Allocator>>
unordered_multiset(initializer_list<_Tp>, _Allocator)
-> unordered_multiset<_Tp, hash<_Tp>, equal_to<_Tp>, _Allocator>;
template<typename _Tp, typename _Hash, typename _Allocator,
typename = _RequireNotAllocatorOrIntegral<_Hash>,
typename = _RequireAllocator<_Allocator>>

View File

@@ -27,7 +27,10 @@ using alloc_type = test_type::allocator_type;
test_type h1(10, alloc_type());
test_type h2(10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), 10, alloc_type());
test_type h4(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h5({ { 1, 1 } }, 10, alloc_type());
test_type h6({ { 1, 1 } }, 10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), alloc_type());
test_type h4(h1.begin(), h1.end(), 10, alloc_type());
test_type h5(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h6({ { 1, 1 } }, alloc_type());
test_type h7({ { 1, 1 } }, 10, alloc_type());
test_type h8({ { 1, 1 } }, 10, hasher_type(), alloc_type());

View File

@@ -15,12 +15,28 @@ static_assert(std::is_same_v<
{2, 3.0}, {3, 4.0}}}),
std::unordered_map<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{{std::pair{1, 2.0},
{2, 3.0}, {3, 4.0}},
SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_map<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{
{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}},
1}),
std::unordered_map<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{
{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}},
1, SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_map<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{{std::pair{1, 2.0},
{2, 3.0}, {3, 4.0}},
@@ -96,6 +112,18 @@ void f()
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{x.begin(), x.end(),
std::allocator<std::pair<const int, double>>{}}),
std::unordered_map<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{x.begin(), x.end(),
SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_map<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_map{x.begin(), x.end(),
1, std::hash<int>{},

View File

@@ -27,7 +27,9 @@ using alloc_type = test_type::allocator_type;
test_type h1(10, alloc_type());
test_type h2(10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), 10, alloc_type());
test_type h4(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h5({ { 1, 1 } }, 10, alloc_type());
test_type h6({ { 1, 1 } }, 10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), alloc_type());
test_type h4(h1.begin(), h1.end(), 10, alloc_type());
test_type h5(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h6({ { 1, 1 } }, alloc_type());
test_type h7({ { 1, 1 } }, 10, alloc_type());
test_type h8({ { 1, 1 } }, 10, hasher_type(), alloc_type());

View File

@@ -15,6 +15,28 @@ static_assert(std::is_same_v<
{2, 3.0}, {3, 4.0}}}),
std::unordered_multimap<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{
{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}},
SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_multimap<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{
{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}},
1}),
std::unordered_multimap<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{
{std::pair{1, 2.0}, {2, 3.0}, {3, 4.0}},
1, SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_multimap<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{{std::pair{1, 2.0},
{2, 3.0}, {3, 4.0}},
@@ -105,6 +127,18 @@ void f()
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{x.begin(), x.end(),
std::allocator<std::pair<const int, double>>{}}),
std::unordered_multimap<int, double>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{x.begin(), x.end(),
SimpleAllocator<std::pair<const int, double>>{}}),
std::unordered_multimap<int, double, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<std::pair<const int, double>>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multimap{x.begin(), x.end(),
1, std::hash<int>{},

View File

@@ -27,7 +27,9 @@ using alloc_type = test_type::allocator_type;
test_type h1(10, alloc_type());
test_type h2(10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), 10, alloc_type());
test_type h4(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h5({ 1, 1 }, 10, alloc_type());
test_type h6({ 1, 1 }, 10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), alloc_type());
test_type h4(h1.begin(), h1.end(), 10, alloc_type());
test_type h5(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h6({ 1, 1 }, alloc_type());
test_type h7({ 1, 1 }, 10, alloc_type());
test_type h9({ 1, 1 }, 10, hasher_type(), alloc_type());

View File

@@ -19,6 +19,22 @@ static_assert(std::is_same_v<
0, std::hash<int>{}, std::allocator<int>{}}),
std::unordered_multiset<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{{1, 2, 3}}),
std::unordered_multiset<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{{1, 2, 3},
std::allocator<int>{}}),
std::unordered_multiset<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{{1, 2, 3},
SimpleAllocator<int>{}}),
std::unordered_multiset<int, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<int>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{{1, 2, 3},
{}}),
@@ -86,6 +102,18 @@ void f()
{}, std::hash<int>{}, std::equal_to<int>{}}),
std::unordered_multiset<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{x.begin(), x.end(),
std::allocator<int>{}}),
std::unordered_multiset<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{x.begin(), x.end(),
SimpleAllocator<int>{}}),
std::unordered_multiset<int, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<int>>>);
static_assert(std::is_same_v<
decltype(std::unordered_multiset{x.begin(), x.end(),
{}, std::hash<int>{}, std::allocator<int>{}}),

View File

@@ -27,7 +27,9 @@ using alloc_type = test_type::allocator_type;
test_type h1(10, alloc_type());
test_type h2(10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), 10, alloc_type());
test_type h4(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h5({ 1, 1 }, 10, alloc_type());
test_type h6({ 1, 1 }, 10, hasher_type(), alloc_type());
test_type h3(h1.begin(), h1.end(), alloc_type());
test_type h4(h1.begin(), h1.end(), 10, alloc_type());
test_type h5(h1.begin(), h1.end(), 10, hasher_type(), alloc_type());
test_type h6({ 1, 1 }, alloc_type());
test_type h7({ 1, 1 }, 10, alloc_type());
test_type h9({ 1, 1 }, 10, hasher_type(), alloc_type());

View File

@@ -19,6 +19,22 @@ static_assert(std::is_same_v<
0, std::hash<int>{}, std::allocator<int>{}}),
std::unordered_set<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{{1, 2, 3}}),
std::unordered_set<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{{1, 2, 3},
std::allocator<int>{}}),
std::unordered_set<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{{1, 2, 3},
SimpleAllocator<int>{}}),
std::unordered_set<int, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<int>>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{{1, 2, 3},
{}}),
@@ -91,6 +107,18 @@ void f()
{})),
std::unordered_set<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{x.begin(), x.end(),
std::allocator<int>{}}),
std::unordered_set<int>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{x.begin(), x.end(),
SimpleAllocator<int>{}}),
std::unordered_set<int, std::hash<int>,
std::equal_to<int>,
SimpleAllocator<int>>>);
static_assert(std::is_same_v<
decltype(std::unordered_set{x.begin(), x.end(), 1}),
std::unordered_set<int>>);