cplusplus / nbballot

Handling of NB comments in response to ballots
14 stars 4 forks source link

US 42-103 24.6.9.1p6 [flat.map.overview] 24.6.10.1p6 [flat.multimap.overview] Clearing when restoring invariants #519

Closed wg21bot closed 1 year ago

wg21bot commented 1 year ago

In 24.6.9.1p6 [flat.map.overview] states: If any member function in 24.6.9.2 exits via an exception, the invariants are restored. [Note 2: This can result in the flat_map being emptied. — end note]

It is unclear how an adaptor can do this. For instance, if one of the underlying sequence containers is a std::array like type (possibly 3rd party) and the other is a std::vector like type (possibly 3rd party) and an exception is thrown during a move assignment, how does the implementation of flat_map restore the invariants? One cannot clear an array, and attempting to resize a vector may fail.

There is an identical issue with flat_multimap.

Proposed change:

Disallow array-like types as the underlying sequence containers (with the understanding that we could add them back in a future standard should this issue be worked out).

We can then require that clear() is called when an exception is thrown and that the post condition c.empty() holds for the underlying containers.

JeffGarland commented 1 year ago

This is related to https://cplusplus.github.io/LWG/issue617 -- TK to write a resolution for 617 post-kona.

https://wiki.edg.com/bin/view/Wg21kona2022/LWG20221107-EA

New issue to add that the containers must meet the sequence container requirements.

JeffGarland commented 1 year ago

https://cplusplus.github.io/LWG/issue3816

Moved to ready for c++23 at Kona

jensmaurer commented 1 year ago

Accept with modifications. See LWG3816 for details.