value::try_at
Access an element, with bounds checking.
Synopsis
boost::system::result< value & >
try_at(
string_view key) noexcept; (1)
boost::system::result< value const & >
try_at(
string_view key) const noexcept; (2)
boost::system::result< value & >
try_at(
std::size_t pos) noexcept; (3)
boost::system::result< value const & >
try_at(
std::size_t pos) const noexcept; (4)
Description
Returns boost::system::result containing a reference to the element of the underlying ccontainer, if such element exists. If the underlying value is not a container of the suitable type or the container doesn’t have a corresponding element the result contains an error_code.
, if pos is within its range. If pos is outside of that range, or the underlying value is not an object the
Returns boost::system::result containing a reference to the element of the underlying array, if pos is within its range. If pos is outside of that range, or the underlying value is not an array the result contains an error_code.
This function is used to access elements of the underlying container, or throw an exception if that could not be done.
Exception Safety
No-throw guarantee.
Parameters
| Name | Description |
|---|---|
|
The key of the element to find. |
|
A zero-based array index. |
Complexity
Constant.
Exception Safety
No-throw guarantee.