C++ Logo

std-discussion

Advanced search

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

From: Daniel Eiband <daniel.eiband_at_[hidden]>
Date: Tue, 5 Jul 2022 16:14:53 +0000
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))?

Cheers,
Daniel

Received on 2022-07-05 16:14:57