(C++17) | ||||
| Sequence | ||||
(C++11) | ||||
(C++26) | ||||
(C++26) | ||||
(C++11) | ||||
| Associative | ||||
| Unordered associative | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
(C++11) | ||||
| Adaptors | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
| Views | ||||
(C++20) | ||||
(C++23) | ||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::stack| Member functions | ||||
| Element access | ||||
| Capacity | ||||
stack::size | ||||
| Modifiers | ||||
(C++23) | ||||
(C++11) | ||||
(C++11) | ||||
| Non-member functions | ||||
(C++11) | ||||
| Helper classes | ||||
(C++11) | ||||
(C++23) | ||||
| Deduction guides(C++17) |
size_type size()const; | ||
Returns the number of elements in the container adaptor. Equivalent to:return c.size().
Contents |
(none)
The number of elements in the container adaptor.
Constant.
#include <cassert>#include <stack> int main(){std::stack<int> stack;assert(stack.size()==0); constint count=8;for(int i=0; i!= count;++i) stack.push(i);assert(stack.size()== count);}
| checks whether the container adaptor is empty (public member function)[edit] | |
(C++17)(C++20) | returns the size of a container or array (function template)[edit] |