object::operator[]

## `object::operator[]`

Access or insert an element.

### Synopsis

    value&
    operator[](
        string_view key);

### Description

Returns a reference to the value that is mapped to `key`. If such value does not already exist, performs an insertion of a null value.

If an insertion occurs and results in a rehashing of the container, all iterators including any past-the-end iterators, and all references to the elements are invalidated. Otherwise, no iterators or references are invalidated.

### Complexity

Constant on average, worst case linear in `size()`.

### Exception Safety

Strong guarantee. Calls to `memory_resource::allocate` may throw.

### Return Value

A reference to the mapped value.

### Parameters

Name | Description
--- | ---
`key` | The key of the element to find.

Edit this page