In C++, std::deque::front() returns the first element of a std::deque. It is the same as d[0], but it reads better.
It returns a reference, so you can read the value or change it. The deque must have at least one element. Include <deque> to use it.
This is a member of std::deque<T>, a double-ended queue. A deque is fast at adding and removing at both ends, and it allows access by index like std::vector. Unlike a vector, its elements are stored in several blocks, not in one contiguous block.
Syntax
Call front with empty brackets. It takes no arguments.
C++
d.front();
d.front() = 1;
Call
What it does
d.front()
Reads the first element.
d.front() = 1
Replaces the first element with a new value.
The last element has a matching function: back(). To remove the first element, use pop_front().
Library declarations
C++
reference front();
const_reference front() const;
Parameters
Parameter
Description
None
front() takes no parameters. Call it with empty brackets.
Return Value
Return Value
Description
Reference
A reference to the first element, which is the same as d[0] and *d.begin().