Size
Let's find out how we can check the size and capacity of C++ containers.
For a container cont
, use cont.empty()
to see if the container is empty. cont.size()
returns the current number of elements, and cont.max_size()
returns the maximum number of elements cont
can have. The maximum number of elements is implementation defined.
Get hands-on with 1400+ tech skills courses.