public member function
<forward_list>
const_iterator cbefore_begin() const noexcept;
Return const_iterator to before beginning
返回一個const_iteratorpointing to the position before the first element in the container.
Aconst_iterator是一個指向常量內容的迭代器。這個迭代器可以像iteratorreturned by forward_list::before_begin, but it cannot be used to modify the contents it points to.
返回的值不應被解引用。
返回值
Aconst_iteratorto the position before the beginning of the sequence.
成員型別const_iterator是一個指向 const 元素的 forward iterator 型別。
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
// forward_list::cbefore_begin
#include <iostream>
#include <forward_list>
int main ()
{
std::forward_list<int> mylist = {77, 2, 16};
mylist.insert_after ( mylist.cbefore_begin(), 19 );
std::cout << "mylist contains:";
for ( int& x: mylist ) std::cout << ' ' << x;
std::cout << '\n';
return 0;
}
|
輸出
mylist contains: 19 77 2 16
|
資料競爭
訪問容器。
呼叫不訪問任何容器中的元素,但返回的迭代器可用於訪問它們。併發訪問或修改不同元素是安全的。
異常安全
無異常保證:此成員函式從不丟擲異常。
還可以保證返回的迭代器的複製構造或賦值永遠不會引發異常。