Difference between revisions of "Template:cpp/container/size"
From cppreference.com
m (+flat_(+) adaptors, examples adjustment: WIP.) |
m (rm flat_(+) since they use size ad.) |
||
Line 15: | Line 15: | ||
|since3=c++20|dcl3= | |since3=c++20|dcl3= | ||
constexpr size_type size() const noexcept; | constexpr size_type size() const noexcept; | ||
− | |||
− | |||
− | |||
− | |||
}} | }} | ||
| | | | ||
Line 40: | Line 36: | ||
===Example=== | ===Example=== | ||
{{#switch:{{{1|}}} | {{#switch:{{{1|}}} | ||
− | |set|multiset|unordered_set|unordered_multiset | + | |set|multiset|unordered_set|unordered_multiset |
={{include|cpp/container/set/example size|{{{1|}}}}} | ={{include|cpp/container/set/example size|{{{1|}}}}} | ||
− | |map|multimap|unordered_map|unordered_multimap | + | |map|multimap|unordered_map|unordered_multimap |
={{include|cpp/container/map/example size|{{{1|}}}}} | ={{include|cpp/container/map/example size|{{{1|}}}}} | ||
|{{include|cpp/container/{{{1|}}}/example size}} | |{{include|cpp/container/{{{1|}}}/example size}} |
Revision as of 08:31, 27 December 2023
size_type size() const noexcept; |
(since {std}) | |
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Contents |
Parameters
(none)
Return value
The number of elements in the container.
Complexity
Constant.
Example
Templated content. The link is cpp/container/<PP>/example size |
See also
checks whether the container is empty (public member function of std::{{{1}}} )
| |
returns the maximum possible number of elements (public member function of std::{{{1}}} )
| |
(C++17)(C++20) |
returns the size of a container or array (function template) |