Skip to content

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

@wg21bot

Description

@wg21bot

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions