public member function
<set>

std::set::cend

const_iterator cend() const noexcept;
返回指向結尾的 const_iterator
返回一個const_iterator指向容器的尾後元素。

All iterators in set containers are constant iterators (including bothconst_iteratoriteratormember types). These cannot be used to modify the contents they point to, but can be increased and decreased normally (unless they are themselves also const).

引數



返回值

Aconst_iterator指向序列末尾的元素。

成員型別const_iterator是一個指向 const 元素的雙向迭代器型別。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// set::cbegin/cend
#include <iostream>
#include <set>

int main ()
{
  std::set<int> myset = {50,20,60,10,25};

  std::cout << "myset contains:";
  for (auto it=myset.cbegin(); it != myset.cend(); ++it)
    std::cout << ' ' << *it;

  std::cout << '\n';

  return 0;
}

輸出
myset contains: 10 20 25 50 60 


複雜度

常量。

迭代器有效性

沒有變化。

資料競爭

訪問容器。
併發訪問set的元素是安全的。

異常安全

無異常保證:此成員函式從不丟擲異常。
還可以保證返回的迭代器的複製構造或賦值永遠不會引發異常。

另見