object::at

Access the specified element, with bounds checking.

Synopsis

value&
at(
    string_view key,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) &; (1)

value&&
at(
    string_view key,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) &&; (2)

value const&
at(
    string_view key,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) const&; (3)

Description

Returns a reference to the mapped value of the element that matches key, otherwise throws.

Complexity

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

Exception Safety

Strong guarantee.

Return Value

A reference to the mapped value.

Return Value

A reference to the mapped value.

Return Value

A reference to the mapped value.

Parameters

Name Description

key

The key of the element to find.

loc

source_location to use in thrown exception; the source location of the call site by default.

Exceptions

Type Thrown On

boost::system::system_error

if no such element exists.