std::vector<T,Allocator>:: size
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
| Member types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
size_type size
(
)
const
;
|
(C++11부터 noexcept)
(C++20부터 constexpr) |
|
컨테이너의 요소 개수를 반환합니다.
목차 |
반환값
std:: distance ( begin ( ) , end ( ) )
복잡도
상수.
예제
다음 코드는
size
를 사용하여
std::
vector
<
int
>
의 요소 개수를 표시합니다:
#include <cassert> #include <vector> int main() { std::vector<int> nums; assert(nums.size() == 0); nums = {1, 2, 3, 4}; assert(nums.size() == 4); }
참고 항목
|
현재 할당된 저장 공간에 보관할 수 있는 요소의 수를 반환합니다
(public member function) |
|
|
컨테이너가 비어 있는지 확인합니다
(public member function) |
|
|
가능한 최대 요소 수를 반환합니다
(public member function) |
|
|
저장된 요소의 수를 변경합니다
(public member function) |
|
|
(C++17)
(C++20)
|
컨테이너나 배열의 크기를 반환합니다
(function template) |