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

4587. Missing complexity for unordered_map::at

Section: 23.5.3.3 [unord.map.elem] Status: Ready Submitter: Pablo Halpern Opened: 2026-06-09 Last modified: 2026-06-15

Priority: Not Prioritized

View all other issues in [unord.map.elem].

View all issues with Ready status.

Discussion:

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

[Brno 2026-06-12; Status changed: New → Ready.]

Proposed resolution:

This wording is relative to N5046.

  1. Modify 23.5.3.3 [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().