C++ Set 库 - cend 函数
描述
它返回一个 const_iterator 指向容器中过去的元素。
声明
以下是 std::set::cend 在各种 C++ 版本中的工作方式。
C++98
const_iterator cend() const noexcept;
C++11
const_iterator cend() const noexcept;
返回值
它返回一个 const_iterator 指向容器中过去的元素。
异常
它从不抛出异常。
时间复杂度
Time complexity is contstant.
示例
以下示例显示了 std::set::cend 的用法。
#include <iostream>
#include <set>
int main () {
std::set<int> myset = {10,20,30,40,50};
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 30 40 50

