[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/container/array/get [Back]  [Original]

std::get(std::array) cppreference.com
cppreference.com

std::get(std::array)

cppreference.com

<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 .
:
Extracts the Ith element element from the array.
Google.
. .
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[]().
Google.
. .

a
,
:
array whose contents to extract
Google.
. .

1)

Ith a.
:
Reference to the Ith element of a.
Google.
. .

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.
Google.
. .

3)

Const Ith a.
:
Const reference to the Ith element of a.
Google.
. .

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)

.


(public -) []
(C++11)

(public -) []

( ) []

( ) []

Web Proxy Viewer  |  New URL  |  Original Page