public member function
<queue>
std::queue::front
value_type& front();const value_type& front() const;
reference& front();const_reference& front() const;
Access next element
The next element is the "oldest" element in the queue and the same element that is popped out from the queue when queue::pop is called.
This member function effectively calls member front of the underlying container object.
Parameters
noneReturn value
A reference to the next element in the queue.
Member type value_type is the type of the elements in the container (defined as an alias of the first class template parameter, T).
Member types reference and const_reference are aliases of the underlying container's types with the same name.
Example
|
|
Output:
myqueue.front() is now 61
Complexity
Constant (calling front on the underlying container).Data races
The container is accessed (neither the const nor the non-const versions modify the container).The reference returned can be used to access or modify the next element.
Exception safety
Provides the same level of guarantees as the operation performed on the container (no-throw guarantee for standard non-empty containers).See also
- queue::pop
- Remove next element (public member function)
- queue::back
- Access last element (public member function)