Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext
array::if_contains (2 of 2 overloads)

Return a pointer to an element, or nullptr if the index is invalid.

Synopsis
value*
if_contains(
    std::size_t pos);
Description

This function returns a pointer to the element at index pos when the index is less then the size of the container. Otherwise it returns null.

Example
if( auto p = arr.if_contains( 1 ) )
    std::cout << *p;
Complexity

Constant.

Exception Safety

No-throw guarantee.

Parameters

Name

Description

pos

The index of the element to return.


PrevUpHomeNext