flat_map and flat_multimap should impose sequence container requirementsSection: 23.6.8.1 [flat.map.overview], 23.6.9.1 [flat.multimap.overview] Status: C++23 Submitter: Tomasz KamiĆski Opened: 2022-11-08 Last modified: 2023-11-22
Priority: Not Prioritized
View all other issues in [flat.map.overview].
View all issues with C++23 status.
Discussion:
This is resolution of US 42-103 (23.6.8.1 [flat.map.overview] p6 23.6.9.1 [flat.multimap.overview] p6 Clearing when restoring invariants).
Currently both 23.6.8.1 [flat.map.overview] p7 and 23.6.9.1 [flat.multimap.overview] p7
claims that flat_(multi)map supports "Any sequence container (23.2.4 [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 23.3.3.1 [array.overview] p3: "An array meets some of the requirements
of a sequence container (23.2.4 [sequence.reqmts])".
[Kona 2022-11-08; Move to Immediate status]
[2022-11-12 Approved at November 2022 meeting in Kona. Status changed: Immediate → WP.]
Proposed resolution:
This wording is relative to N4917.
Modify 23.6.8.1 [flat.map.overview] as indicated:
-7- Any
sequence container (23.2.4 [sequence.reqmts])typeCsupporting Cpp17RandomAccessIteratorthat meets sequence container requirements (23.2.4 [sequence.reqmts]) can be used to instantiateflat_map, as long asC::iteratormeets the Cpp17RandomAccessIterator requirements and invocations of member functionsC::sizeandC::max_sizedo not exit via an exception. In particular,vector(23.3.13 [vector]) anddeque(23.3.5 [deque]) can be used.
Modify 23.6.9.1 [flat.multimap.overview] as indicated:
-7- Any
sequence container (23.2.4 [sequence.reqmts])typeCsupporting Cpp17RandomAccessIteratorthat meets sequence container requirements (23.2.4 [sequence.reqmts]) can be used to instantiateflat_multimap, as long asC::iteratormeets the Cpp17RandomAccessIterator requirements and invocations of member functionsC::sizeandC::max_sizedo not exit via an exception. In particular,vector(23.3.13 [vector]) anddeque(23.3.5 [deque]) can be used.