std::flat_map<Key,T,Compare,KeyContainer,MappedContainer>::size

Returns the number of elements in the container adaptor. Equivalent to: returnc.keys.size().

# Declarations

size_type size() const noexcept;

(since C++23)

# Return value

The number of elements in the container adaptor.

# Example

#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); 
}

# See also