VOOZH about

URL: https://www.geeksforgeeks.org/cpp/deque-crend-in-c-stl/

⇱ deque crend in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

deque crend in C++ STL

Last Updated : 20 Feb, 2023

The deque::crend() is an inbuilt function in C++ STL which returns a constant reverse iterator which points to the position before the first element of the deque. Syntax 

deque_name.crend()

Parameters: This function does not accept any parameters. Return Type: This function returns constant reverse iterator of deque. Example-1: 

Output:
The deque in reverse order: 
10
20
30
40
50

Example-2: Since the iterator is constant, making an attempt to change it would cause error. 

Compilation Error in CPP code :- prog.cpp: In function 'int main()': prog.cpp:15:13: error: assignment of read-only location 'it.std::reverse_iterator<_Iterator>::operator* >()' *it = 'g' ^ prog.cpp:17:5: error: expected ';' before 'return' return 0; ^

Time complexity: O(N). // N is the size of the deque.

Auxiliary space: O(1)

Comment
Article Tags: