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 object, or throw an exception if the value is not an object.

Complexity

Constant.

Exception Safety

Strong guarantee.

Return Value

this->as_object(loc).at( key, loc ).

Return Value

this->as_object(loc).at( key, loc ).

Return Value

this->as_object(loc).at( key, loc ).

Return Value

this->as_array(loc).at( pos, loc ).

Return Value

this->as_array(loc).at( pos, loc ).

Return Value

this->as_array(loc).at( pos, loc ).

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.

pos

A zero-based array index.