Title
flat_map and flat_multimap should impose sequence container requirements
Status
c++23
Section
[flat.map.overview][flat.multimap.overview]
Submitter
Tomasz Kamiński

Created on 2022-11-08.00:00:00 last changed 12 months ago

Messages

Date: 2022-11-17.00:42:33

Proposed resolution:

This wording is relative to N4917.

  1. Modify [flat.map.overview] as indicated:

    -7- Any sequence container ([sequence.reqmts])type C supporting Cpp17RandomAccessIteratorthat meets sequence container requirements ([sequence.reqmts]) can be used to instantiate flat_map, as long as C::iterator meets the Cpp17RandomAccessIterator requirements and invocations of member functions C::size and C::max_size do not exit via an exception. In particular, vector ([vector]) and deque ([deque]) can be used.

  2. Modify [flat.multimap.overview] as indicated:

    -7- Any sequence container ([sequence.reqmts])type C supporting Cpp17RandomAccessIteratorthat meets sequence container requirements ([sequence.reqmts]) can be used to instantiate flat_multimap, as long as C::iterator meets the Cpp17RandomAccessIterator requirements and invocations of member functions C::size and C::max_size do not exit via an exception. In particular, vector ([vector]) and deque ([deque]) can be used.

Date: 2022-11-12.00:00:00

[ 2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP. ]

Date: 2022-11-08.22:46:43

[ Kona 2022-11-08; Move to Immediate status ]

Date: 2022-11-08.00:00:00

This is resolution of US 42-103 ([flat.map.overview] p6 [flat.multimap.overview] p6 Clearing when restoring invariants).

Currently both [flat.map.overview] p7 and [flat.multimap.overview] p7 claims that flat_(multi)map supports "Any sequence container ([sequence.reqmts]) C supporting Cpp17RandomAccessIterator", which arguably includes std::array (see LWG 617). This is incorrect as std::array does not provide operations required to restored these adaptors invariant, including clear. We should require that C meets sequence container requirements, and we state that fact explicitly in [array.overview] p3: "An array meets some of the requirements of a sequence container ([sequence.reqmts])".

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2022-11-17 00:42:33adminsetmessages: + msg13094
2022-11-17 00:42:33adminsetstatus: immediate -> wp
2022-11-08 22:46:43adminsetmessages: + msg12967
2022-11-08 22:46:43adminsetstatus: new -> immediate
2022-11-08 16:38:45adminsetmessages: + msg12959
2022-11-08 00:00:00admincreate