This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3816. flat_map and flat_multimap should impose sequence container requirements

Section: 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(i)). 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.

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

    -7- Any sequence container (23.2.4 [sequence.reqmts])type C supporting Cpp17RandomAccessIteratorthat meets sequence container requirements (23.2.4 [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 (23.3.11 [vector]) and deque (23.3.5 [deque]) can be used.

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

    -7- Any sequence container (23.2.4 [sequence.reqmts])type C supporting Cpp17RandomAccessIteratorthat meets sequence container requirements (23.2.4 [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 (23.3.11 [vector]) and deque (23.3.5 [deque]) can be used.