std::hive<T,Allocator>::size
来自 zh.cppreference.net
size_type size() const noexcept;
|
(自 C++26 起) | |
返回容器中的元素数,即std::distance(begin(), end()).
返回值
容器中的元素数。
复杂度
常数。
示例
运行此代码
#include <cassert>
#include <hive>
int main()
{
std::hive<int> bees;
assert(bees.size() == 0);
bees = {1, 2, 3, 4};
assert(bees.size() == 4);
}
参阅
| 检查容器是否为空 (公开成员函数) | |
| 返回可能的最大元素数 (公开成员函数) | |
(C++17)(C++20) |
返回容器或数组的大小 (函数模板) |