vector::cend (c++ 11)

网友投稿 270 2022-08-27

vector::cend (c++ 11)

public member function

std::vector::cend

const_iterator cend() const noexcept;

Return const_iterator to end

Returns a const_iterator pointing to the past-the-end element in the container.

A const_iterator is an iterator that points to const content. This iterator can be increased and decreased (unless it is itself also const), just like the iterator returned by ​​vector::end​​​, but it cannot be used to modify the contents it points to, even if the ​​vector​​ object is not itself const.

If the container is ​​empty​​​, this function returns the same as ​​vector::cbegin​​.

The value returned shall not be dereferenced.

Parameters

none

Return Value

A const_iterator to the element past the end of the sequence.

Member type const_iterator is a ​​random access iterator​​ type that points to a const element.

// vector::cbegin/cend#include #include using namespace std;int main (){ vector myvector = {10,20,30,40,50}; cout << "myvector contains:"; for (auto it = myvector.cbegin(); it != myvector.cend(); ++it) cout << ' ' << *it; cout << '\n'; return 0;}

Output:

myvector contains: 10 20 30 40 50

Complexity (复杂性)

Constant.

Iterator validity

No changes.

该方法不会对其他迭代器的有效性造成影响。

Data races

The container is accessed.

该容器应该是可访问的。

No contained elements are accessed by the call, but the iterator returned can be used to access them. Concurrently accessing or modifying different elements is safe.

Exception safety

No-throw guarantee: this member function never throws exceptions.

The copy construction or assignment of the returned iterator is also guaranteed to never throw.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:返乡置业,会成为营销鸡肋吗?
下一篇:HDU 5748 BestCoder Round #84 Bellovin (LIS)(树状数组)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~