C++ Logo


Advanced search

Re: Deduction guide of std::unordered_map for iterator range and allocator

From: Daniel Eiband <daniel.eiband_at_[hidden]>
Date: Tue, 5 Jul 2022 17:55:23 +0000
Hi Daniel,

Thank you for the link to LWG 2713! It is good to see these overloads to be added.

However it still seems like the following deduction guides for the set types std::unordered_set and std::unordered_multiset are missing:

unordered_set(InputIterator, InputIterator, Allocator)
unordered_set(initializer_list<T>, Allocator)

unordered_multiset(InputIterator, InputIterator, Allocator)
unordered_multiset(initializer_list<T>, Allocator)

As far as I can see, for the map types std::unordered_map and std::unordered_multimap they are already in C++17, but not for the set types and LWG 2713 does not introduce them either.


-----Original Message-----
From: Daniel Krügler <daniel.kruegler_at_[hidden]>
Sent: Dienstag, 5. Juli 2022 18:33
To: Std-Discussion <std-discussion_at_[hidden]>
Cc: Daniel Eiband <daniel.eiband_at_[hidden]>
Subject: Re: [std-discussion] Deduction guide of std::unordered_map for iterator range and allocator

[You don't often get email from daniel.kruegler_at_gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

Am Di., 5. Juli 2022 um 18:15 Uhr schrieb Daniel Eiband via Std-Discussion <std-discussion_at_[hidden]>:
> Hi,
> std::unordered_map has the following deduction guide:
> template<class InputIterator, class 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>;
> However there seems to be no constructor with this signature. std::unordered_set does not have a deduction guide for iterator range + allocator. Interestingly, the Microsoft implementation provides constructors with this signature for std::unordered_map and std::unordered_set. I have created an example to illustrate this:
> https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgodb
> olt.org%2Fz%2FoTox5ojPW&amp;data=05%7C01%7Cdaniel.eiband%40brainlab.co
> m%7C823dac7641eb45525a1208da5ea41f6d%7Ce904fb52a46f4d6bad976dc605bf387
> 9%7C0%7C0%7C637926356240428327%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjA
> wMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&am
> p;sdata=skQU23cM7WgzHBbqD0Vgx27eF0V1I43P1e13Ns8bssk%3D&amp;reserved=0
> Is this a standard defect? Are there any plans to add these constructor overloads (and maybe also the deduction guide unordered_set(InputIterator, InputIterator, Allocator))?

Yes, this is a defect and already reported here:


- Daniel

Received on 2022-07-05 17:55:26