Title
Missing complexity for unordered_map::at
Status
new
Section
[unord.map.elem]
Submitter
Pablo Halpern

Created on 2026-06-09.00:00:00 last changed yesterday

Messages

Date: 2026-06-09.13:01:00

Proposed resolution:

This wording is relative to N5046.

  1. Modify [unord.map.elem] as indicated:

    constexpr mapped_type& at(const key_type& k);
    constexpr const mapped_type& at(const key_type& k) const;
    

    -5- Returns: A reference to `x.second`, where `x is the (unique) element whose key is equivalent to `k`.

    -6- Throws: An exception object of type `out_of_range` if no such element is present.

    -?- Complexity: Average case constant, worst case linear in `size()`.

    template<class K> constexpr mapped_type&       at(const K& k);
    template<class K> constexpr const mapped_type& at(const K& k) const;
    

    -7- Constraints: The qualified-ids `Hash::is_transparent` and `Pred::is_transparent` are valid and denote types.

    -8- Preconditions: The expression `find(k)` is well-formed and has well-defined behavior.

    -9- Returns: A reference to `find(k)->second`.

    -10- Throws: An exception object of type `out_of_range` if `find(k) == end()` is `true`.

    -?- Complexity: Average case constant, worst case linear in `size()`.

Date: 2026-06-09.00:00:00

During review of P3091R5 Pablo pointed out that there is no Complexity: element for `unordered_map::at`.

History
Date User Action Args
2026-06-09 13:01:00adminsetmessages: + msg16376
2026-06-09 00:00:00admincreate