Title
Containers need deduction guides
Status
resolved
Section
[containers]
Submitter
United States

Created on 2017-02-03.00:00:00 last changed 93 months ago

Messages

Date: 2017-03-15.00:00:00

[ 2017-03-12, post-Kona ]

Resolved by P0433R2.

Date: 2017-02-03.00:00:00
Addresses US 147

One of the motivating features behind deduction guides was constructing containers from a pair of iterators, yet the standard library does not provide any such deduction guides. They should be provided in header synopsis for each container in clause 23. It is expected that the default arguments from the called constructors will provide the context to deduce any remaining class template arguments, such as the Allocator type, and default comparators/hashers for (unordered) associative containers. At this stage, we do not recommend adding additional guides to deduce a (rebound) allocator, comparator etc. due to the likely large number of such guides. It is noted that the requirements on iterator_traits to be an empty type will produce a SFINAE condition to allow correct deduction for vector in the case of the Do-The-Right-Thing clause, resolving ambiguity between two integers, and two iterators.

Proposed change: For each container in clause 23, add to the header synopsis a deduction guide of the form

template <class Iterator>
container(Iterator, Iterator) -> container<typename iterator_traits<Iterator>::value_type>;
History
Date User Action Args
2017-03-12 23:04:12adminsetmessages: + msg9086
2017-03-12 23:04:12adminsetstatus: new -> resolved
2017-02-03 00:00:00admincreate