[map.access]

# 23 Containers library [[containers]](./#containers)

## 23.4 Associative containers [[associative]](associative#map.access)

### 23.4.3 Class template map [[map]](map#access)

#### 23.4.3.3 Element access [map.access]

[ð](#lib:operator%5b%5d,map)

`constexpr mapped_type& operator[](const key_type& x);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11815)

*Effects*: Equivalent to: return try_emplace(x).first->second;

[ð](#lib:operator%5b%5d,map_)

`constexpr mapped_type& operator[](key_type&& x);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11826)

*Effects*: Equivalent to: return try_emplace(std​::​move(x)).first->second;

[ð](#lib:operator%5b%5d,map__)

`template<class K> constexpr mapped_type& operator[](K&& x);
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11837)

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") Compare​::​is_transparent is valid and denotes a type[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11842)

*Effects*: Equivalent to: return try_emplace(std​::​forward<K>(x)).first->second;

[ð](#lib:at,map)

`constexpr mapped_type&       at(const key_type& x);
constexpr const mapped_type& at(const key_type& x) const;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11854)

*Returns*: A reference to the mapped_type corresponding to x in *this[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11858)

*Throws*: An exception object of type out_of_range if
no such element is present[.](#6.sentence-1)

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11863)

*Complexity*: Logarithmic[.](#7.sentence-1)

[ð](#lib:at,map_)

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

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11875)

*Constraints*: The [*qualified-id*](expr.prim.id.qual#nt:qualified-id "7.5.5.3 Qualified names [expr.prim.id.qual]") Compare​::​is_transparent is valid and denotes a type[.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11880)

*Preconditions*: The expression find(x) is well-formed and has well-defined behavior[.](#9.sentence-1)

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11884)

*Returns*: A reference to find(x)->second[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11888)

*Throws*: An exception object of type out_of_range iffind(x) == end() is true[.](#11.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/containers.tex#L11893)

*Complexity*: Logarithmic[.](#12.sentence-1)
