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

  1. Shows an error if a parameter is passed.
  2. 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.

Similar Reads

queue::empty()

empty() function is used to check if the queue container is empty or not....

Examples of queue::empty()

Example 1...

queue::size()

...

Examples of queue::size()

...