std::array<T,N>::size

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

# Declarations

constexpr size_type size() const noexcept;

(since C++11)

# Return value

The number of elements in the container.

# Example

#include <array>
#include <iostream>
 
int main()
{ 
    std::array<int, 4> nums{1, 3, 5, 7};
 
    std::cout << "nums contains " << nums.size() << " elements.\n";
}

# See also