C++ Logo

std-discussion

Advanced search

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

From: Daniel Krügler <daniel.kruegler_at_[hidden]>
Date: Tue, 5 Jul 2022 18:33:28 +0200
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://godbolt.org/z/oTox5ojPW
>
> 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:

https://cplusplus.github.io/LWG/issue2713

- Daniel

Received on 2022-07-05 16:33:36