std::multis...tiset::cend(3)
okay bestie, buckle up: this is std::multis...tiset::cend(3) from the C++ Standard Libary manual, and we are gonna make end iterators feel iconic πβ¨
π NAME π
std::multiset::end,std::multiset::cend - std::multiset::end,std::multiset::cend
that's the name, no cap. end and cend are both living here together.
β¨ Synopsis β¨
the signature lineup, exactly:
iterator end(); (1) (noexcept since C++11)
const_iterator end() const; (2) (noexcept since C++11)
const_iterator cend() const noexcept; (3) (since C++11)
Returns an iterator to the element following the last element of the multiset.
This element acts as a placeholder; attempting to access it results in undefined behavior.
there's also a diagram placeholder on the page: range-begin-end.svg π¦
πΈ Parameters πΈ
(none) β literally none, bestie. zero parameters, zero drama.
π¦ Return value π¦
Iterator to the element following the last element.
π Complexity π
Constant. always and forever.
π Notes π
Because both iterator and const_iterator are constant iterators (and may in fact be the same type), it is not possible to mutate the elements of the container through an iterator returned by any of these member functions.
so yeah, no sneaky edits through these iterators β that's the whole vibe π
Also: libc++ backports cend() to C++98 mode. periodt.
π Example π
the page says // Run this code, and then this exact block:
#include <iostream>
#include <iterator>
#include <set>
#include <string>
int main()
{
const std::multiset<std::string> words =
{
"some", "not", "sorted", "words",
"will", "come", "out", "sorted",
};
for (auto it = words.begin(); it != words.end(); )
{
auto count = words.count(*it);
std::cout << *it << ":\t" << count << '\n';
std::advance(it, count); // all count elements have equivalent keys
}
}
π Output: π
come: 1
not: 1
out: 1
some: 1
sorted: 2
will: 1
words: 1
π See also π
the see-also table is a lil squished in the original, so here's every crumb exactly as it appears:
begin returns an iterator to the beginning
cbegin (public member function)
(C++11)
end
cend returns an iterator to the end of a container or array
(C++11) (function template)
(C++14)
mwah π that's the whole page β source http://cppreference.com, version/date 2024.06.10, page std::multis...tiset::cend(3). byeee π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms