In C++, std::string::cend() returns a const_iterator to one past the last character.
Pair it with cbegin() for read-only loops. Include <string>. (C++11)
This is a member of std::string. A string grows as you append, stores characters contiguously, and can reallocate—after growth, old iterators and references may be invalid. Prefer at() when you want bounds checks; remember find returns npos when missing.
Syntax
Use as the stop iterator for const walks.
C++
for (auto it = s.cbegin(); it != s.cend(); ++it) { }
Call
What it does
s.cend()
Const past-the-end iterator.
Never dereference cend().
Library declarations
C++
const_iterator cend() const noexcept;
Parameters
Parameter
Description
None
cend() takes no parameters. Call it with empty brackets.