queue::size()
size() function is used to return the size of the list container which is the number of elements currently stored in the list container.
Syntax
queuename.size()
Parameters
- This function does not accept any parameter.
Return Value
- It returns the number of elements stored in the container.
Examples
Input : myqueue = 1, 2, 3 myqueue.size(); Output : 3 Input : myqueue myqueue.size(); Output : 0
Errors and Exceptions
- Shows an error if a parameter is passed.
- Shows no exception throw guarantee.
queue::empty() and queue::size() in C++ STL
Queue is a type of container adaptor that operate in a first in first out (FIFO) type of arrangement. Elements are inserted at the back (end) and are deleted from the front.