Megosztás a következőn keresztül:


cend

Retrieves a const iterator to the element that follows the last element in the specified container.

template<class Container>
    auto cend(const Container& cont) 
        -> decltype(cont.end());

Parameters

  • cont
    A container or initializer_list.

Return Value

A constant cont.end().

Remarks

This function works with all STL containers and with initializer_list.

You can use this member function in place of the end() template 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 or initializer_list 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

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

<iterator>

begin

cbegin

end