std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::size - cppreference.com
来自cppreference.com
size_type size() const noexcept; |
(C++23 起) | |
返回容器适配器中的元素数,等价于:return c.keys.size()。
返回值
容器适配器中的元素数。
复杂度
常数。
示例
#include <cassert> #include <flat_map> int main() { std::flat_map<int, char> nums{{1, 'a'}, {1, 'b'}, {2, 'c'}, {2, 'd'}}; assert(nums.size() == 2); }