std::get(std::array)
cppreference.com
[] |
Google. . , . , . |
<metanoindex/>
<tbody> </tbody> template<size_t I, class T, size_t N > T& get( array<T,N>& a ); |
(1) | ( C++11) |
template<size_t I, class T, size_t N > T&& get( array<T,N>&& a ); |
(2) | ( C++11) |
template<size_t I, class T, size_t N > const T& get( const array<T,N>& a ); |
(3) | ( C++11) |
Ith . I [0, N). , at() operator[]().:
I must be an integer value in range [0, N). This is enforced at compile time as opposed to at() or operator[]().| a | ,
|
1)
2)
RValue
Ith a, , .:
Rvalue reference to the
Ith element of a, unless the element is of lvalue reference type, in which case lvalue reference is returned.3)
noexcept:
noexcept#include <iostream>
#include <array>
int main()
{
std::array<int, 3> arr;
// set values:
std::get<0>(arr) = 1;
std::get<1>(arr) = 2;
std::get<2>(arr) = 3;
// get values:
std::cout << "(" << std::get<0>(arr) << ", " << std::get<1>(arr)
<< ", " << std::get<2>(arr) << ")\n";
}
:
(1, 2, 3)
.
(C++11) |
(public -) |
(C++11) |
(public -) |
(C++11) |
( ) |
(C++11) |
( ) |