Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
STL Containers
bitset
deque
list
map
multimap
multiset
priority_queue
queue
set
stack
vector
deque
comparison operators
deque::deque
deque::~deque
member functions:
deque::assign
deque::at
deque::back
deque::begin
deque::clear
deque::empty
deque::end
deque::erase
deque::front
deque::get_allocator
deque::insert
deque::max_size
deque::operator=
deque::operator[]
deque::pop_back
deque::pop_front
deque::push_back
deque::push_front
deque::rbegin
deque::rend
deque::resize
deque::size
deque::swap


deque::front

public member function
      reference front ( );
const_reference front ( ) const;

Access first element

Returns a reference to the first element in the deque container.

Unlike member deque::begin, which returns an iterator to this same element, this function returns a direct reference.

Parameters

none

Return value

A reference to the first element in the deque container.

Member types reference and const_reference are the reference types to the elements of the container (for the default storage allocation model, allocator, these are T& and const T& respectively).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// deque::front
#include <iostream>
#include <deque>
using namespace std;
int main ()
{
  deque<int> mydeque;
  mydeque.push_front(77);
  mydeque.push_back(16);
  mydeque.front() -= mydeque.back();
  cout << "mydeque.front() is now " << mydeque.front() << endl;
  return 0;
}


Output:
mydeque.front() is now 61

Complexity

Constant.

See also