std::multimap<Key,T,Compare,Allocator>::size
来自 zh.cppreference.net
size_type size() const;
|
(noexcept 自 C++11) | |
返回容器中的元素数,即 std::distance(begin(), end())。
返回值
std:: distance ( begin ( ) , end ( ) )
复杂度
常量。
示例
运行此代码
#include <cassert> #include <map> int main() { std::multimap<int, char> nums{{1, 'a'}, {1, 'b'}, {2, 'c'}, {2, 'd'}}; assert(nums.size() == 4); }
参见
|
检查容器是否为空
(公开成员函数) |
|
|
返回可能容纳的最大元素数
(公开成员函数) |
|
|
(C++17)
(C++20)
|
返回容器或数组的大小
(函数模板) |