forward_list::cbefore_begin() in C++ STL

To faithfully explain the concept of forward_list::cbefore_begin() in C++ STL. We first discussed the List in C++n programming language's code and output below. The forward list c before begin function is an in-built functionality in STL [Standard Template Library (STL)]. It returns a constant random-access iterator which points to the position before the first element of the forward_list.

List in C++ STL

C++ code

Output:

The List 1 has elements  : 	0	2	4	6	8	10	12	14	16	18

List 2 has elements : 	27	24	21	18	15	12	9	6	3	0

 list1.front() : 0
 list1.back() : 18
 list1.pop_front() : 	2	4	6	8	10	12	14	16	18

 list2.pop_back() : 	27	24	21	18	15	12	9	6	3

 list1.reverse() : 	18	16	14	12	10	8	6	4	2

list2.sort(): 	3	6	9	12	15	18	21	24	27

Syntax of forward_list::cbefore_begin()

C++ code

Output:

the elements which have gotten inserted are as follows
10 20 30 40 50





Latest Courses