value::at
Access an 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)
value&
at(
std::size_t pos,
boost::source_location const& loc = BOOST_CURRENT_LOCATION) &; (4)
value&&
at(
std::size_t pos,
boost::source_location const& loc = BOOST_CURRENT_LOCATION) &&; (5)
value const&
at(
std::size_t pos,
boost::source_location const& loc = BOOST_CURRENT_LOCATION) const&; (6)
Description
This function is used to access elements of the underlying container, or throw an exception if that could not be done.
-
(1)–(3) is equivalent to
this->as_object(loc).at(key, loc). -
(4)–(6) is equivalent to
this->as_array(loc).at(pos, loc).
Complexity
Constant.
Exception Safety
Strong guarantee.
Parameters
| Name | Description |
|---|---|
|
The key of the element to find. |
|
|
|
A zero-based array index. |
Exceptions
| Type | Thrown On |
|---|---|
|
The underlying type of value is not the container type corresponding to the first argument (i.e. using an index with an |
|
An element corresponding to the first argument was not found. |