C++ STL 中的 forward_list::cbefore_begin()

2024 年 8 月 28 日 | 3 分钟阅读

为了忠实地解释 C++ STL 中 forward_list::cbefore_begin() 的概念。我们首先在下面讨论了 C++ 编程语言代码中的列表及其输出。forward list c before begin 函数是 STL [标准模板库 (STL)] 中的一个内置功能。它返回一个常量随机访问迭代器,指向 forward_list 第一个元素之前的位置。

C++ STL 中的列表

C++ 代码

输出

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

forward_list::cbefore_begin() 的语法

C++ 代码

输出

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