English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ Usage and example of Deque crend()

C++ Deque (Double-ended Queue)

C ++ The Deque crend() function is used to return an iterator pointing to the element before the first element of the deque container. The iterator can be incremented or decremented, but cannot modify the content of the deque.

Syntax

const_reverse_iterator crend();

Parameters

It does not contain any parameters.

Return value

It returns a constant reverse iterator that refers to the element before the first element of the deque container.

Example

Let's look at a simple example

#include<iostream>
#include<deque>
using namespace std;
int main()
{
   deque<char> c = {'l', 'a', 'p', 't', 'o', 'p'};
   deque<char>::const_reverse_iterator citr = c.crbegin();
  cout << "Reverse deque:";
   while(citr != c.crend())
   {
       cout<<*citr;
       ++citr;
   }
   return 0;

Output:

Reverse deque: potpal

In this example, the while loop iterates until citr is not equal to c.crend().

C++ Deque (Double-ended Queue)