std::stack<T,Container>::size
| size_type size() const; |
||
Returns the number of elements in the underlying container, that is, c.size().
Contents |
[edit] Parameters
(none)
[edit] Return value
The number of elements in the container.
[edit] Complexity
Constant.
[edit] Example
#include <algorithm> #include <iostream> #include <stack> int main() { std::stack<int> container; std::cout << "Initially, container.size(): " << container.size() << '\n'; for (int i = 0; i < 7; ++i) container.push(i); std::cout << "After adding elements, container.size(): " << container.size() << '\n'; }
Output:
Initially, container.size(): 0 After adding elements, container.size(): 7
[edit] See also
| checks whether the underlying container is empty (public member function) |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
