vector::cend

Returns a const iterator that point to one past the last element in the vector.

const_iterator cend() const;

Return Value

A const random-access iterator.

Remarks

cend is used to test whether an iterator has passed the last element in the vector.

You can use this member function in place of the end() member function to guarantee that the return value is const_iterator. Typically, it's used in conjunction with the auto type deduction keyword, as shown in the following example. In the example, consider Container to be a modifiable (non-const) container of any kind that supports end() and cend().

auto i1 = Container.end();  // i1 is Container<T>::iterator 
auto i2 = Container.cend(); // i2 is Container<T>::const_iterator

The value returned by cend should not be dereferenced.

Requirements

Header: <vector>

Namespace: std

See Also

Reference

vector Class

Standard Template Library