std::flat_set<Key,Compare,KeyContainer>:: size
From cppreference.net
C++
Containers library
|
(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 |
std::flat_set
|
size_type size
(
)
const
noexcept
;
|
(自 C++23 起) | |
返回容器适配器中的元素数量。等价于:
return
c
.
size
(
)
。
目录 |
参数
(无)
返回值
容器适配器中的元素数量。
复杂度
常量。
示例
运行此代码
#include <cassert> #include <flat_set> int main() { std::flat_set<int> nums{4, 2, 4, 2}; assert(nums.size() == 2); }
参见
|
检查容器适配器是否为空
(公开成员函数) |
|
|
(C++17)
(C++20)
|
返回容器或数组的大小
(函数模板) |
|
返回可能容纳的最大元素数
(公开成员函数) |