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

3816. flat_map and flat_multimap should impose sequence container requirements

Section: 24.6.9.1 [flat.map.overview], 24.6.10.1 [flat.multimap.overview] Status: WP Submitter: Tomasz KamiƄski Opened: 2022-11-08 Last modified: 2022-11-17

Priority: Not Prioritized

View all issues with WP status.

Discussion:

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

Currently both 24.6.9.1 [flat.map.overview] p7 and 24.6.10.1 [flat.multimap.overview] p7 claims that flat_(multi)map supports "Any sequence container (24.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 24.3.7.1 [array.overview] p3: "An array meets some of the requirements of a sequence container (24.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 24.6.9.1 [flat.map.overview] as indicated:

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

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

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