public member function
<array>
std::array::atreference at ( size_type n );const_reference at ( size_type n ) const;
Access element
Returns a reference to the element at position n in the array.The function automatically checks whether n is within the bounds of valid elements in the container, throwing an out_of_range exception if it is not (i.e., if n is greater than, or equal to, its size). This is in contrast with member operator[], that does not check against bounds.
If the array object is const-qualified, the function returns a const_reference. Otherwise, it returns a reference.
Member types reference and const_reference are the reference types to the elements of the array (see array member types).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// array::at
#include <iostream>
#include <array>
int main ()
{
std::array<int,10> myarray;
// assign some values:
for (int i=0; i<10; i++) myarray.at(i) = i+1;
// print content:
std::cout << "myarray contains:";
for (int i=0; i<10; i++)
std::cout << ' ' << myarray.at(i);
std::cout << '\n';
return 0;
}
myarray contains: 1 2 3 4 5 6 7 8 9 10
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4