2007. Incorrect specification of return value for map<>::at()

Section: [map.access] Status: C++11 Submitter: Matt Austern Opened: 2010-11-01 Last modified: 2016-02-10

Priority: Not Prioritized

View all other issues in [map.access].

View all issues with C++11 status.


In [map.access]/9, the Returns clause for map<Key, T>::at(x) says that it returns "a reference to the element whose key is equivalent to x." That can't be right. The signature for at() says that its return type is T, but the elements of map<Key, T> have type pair<const K, T>. (I checked [unord.map.elem] and found that its specification of at() is correct. This is a problem for map only.)

Proposed resolution:

Change the wording in [map.access]/9 so it's identical to what we already say for operator[], which is unambiguous and correct.

Returns: A reference to the element whose key is equivalentmapped_type corresponding to x in *this.