array::at

Access an element, with bounds checking.

Synopsis

value&
at(
    std::size_t pos,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) &; (1)

value&&
at(
    std::size_t pos,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) &&; (2)

value const&
at(
    std::size_t pos,
    boost::source_location const& loc = BOOST_CURRENT_LOCATION) const&; (3)

Description

Returns a reference to the element specified at location pos, with bounds checking. If pos is not within the range of the container, an exception of type boost::system::system_error is thrown.

Complexity

Constant.

Parameters

Name Description

pos

A zero-based index.

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

pos >= size().