Skip to content

[Bug]: Could you document something about the state of moved-from hash maps? #1928

@inazarenko

Description

@inazarenko

Describe the issue

I couldn't find any documentation as to which methods, if any, are safe to call on a moved-from flat_hash_map.

I assume Abseil follows the STL convention that "moved-from objects shall be placed in a valid but unspecified state".

Does it mean that, at a minimum, clear() on such a container is safe to call and will work as expected (resulting in an empty container)? Or perhaps it's only safe to call operator=(/* empty map */T{})?

Empirically, it seems that calling size() is not safe, at least in ASAN'd code:

https://godbolt.org/z/MTos6Kn5r

Steps to reproduce the problem

This is a documentation problem.

What version of Abseil are you using?

Example uses 20250127, but the documentation question applies to all recent versions.

What operating system and version are you using?

N/A

What compiler and version are you using?

N/A

What build system are you using?

N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions