std::array<T,N>::size
cppreference.net에서
constexpr size_type size() const noexcept;
|
(C++11부터) | |
컨테이너에 있는 요소의 개수, 즉 std::distance(begin(), end())를 반환합니다.
반환값
std:: distance ( begin ( ) , end ( ) )
복잡도
상수.
예제
다음 코드는
size
를 사용하여
std::array
내 요소의 개수를 표시합니다:
이 코드 실행
#include <array> #include <iostream> int main() { std::array<int, 4> nums{1, 3, 5, 7}; std::cout << "nums contains " << nums.size() << " elements.\n"; }
출력:
nums contains 4 elements.
참고 항목
|
컨테이너가 비어 있는지 확인합니다
(public member function) |
|
|
가능한 최대 요소 개수를 반환합니다
(public member function) |
|
|
(C++17)
(C++20)
|
컨테이너나 배열의 크기를 반환합니다
(function template) |