set::cend
描述 (Description)
它返回一个const_iterator,指向容器中的past-the-end元素。
声明 (Declaration)
以下是std :: set :: cend在各种C ++版本中的工作方式。
C++98
const_iterator cend() const noexcept;
C++11
const_iterator cend() const noexcept;
返回值
它返回一个const_iterator,指向容器中的past-the-end元素。
异常 (Exceptions)
它从不抛出异常。
时间复杂
时间复杂性是不变的。
例子 (Example)
以下示例显示了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