std::set::e...::set::cend(3)
β¨ NAME β¨
okay so bestie, welcome to the std::set::end,std::set::cend page from the C++ Standard Libary manual, section 3 β and yes, the original header spells it "Libary", I'm just preserving the detail π. The name is std::set::end,std::set::cend, and the description is also std::set::end,std::set::cend. It's giving "the page title literally repeats itself and still ate", but every fact is staying right here.
πΈ Synopsis πΈ
these are the three signatures, literally:
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 set.
This element acts as a placeholder; attempting to access it results in undefined behavior. (Translation: do not dereference it, bestie β that's undefined behavior and we don't play like that.)
There's a range-begin-end.svg diagram in the original too β cute visual, same energy.
π¦ Parameters π¦
(none) β she takes zero parameters, absolutely no notes.
π Return value π
Iterator to the element following the last element. That's the whole return value, periodt.
π₯ Complexity π₯
Constant. That's it, no extra math homework.
π Notes π
- Because both
iteratorandconst_iteratorare 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. libc++backportscend()to C++98 mode.
π Example π
// Run this code
#include <algorithm>
#include <iostream>
#include <set>
int main()
{
std::set<int> set{3, 1, 4, 1, 5, 9, 2, 6, 5};
std::for_each(set.cbegin(), set.cend(), [](int x)
{
std::cout << x << ' ';
});
std::cout << '\n';
}
Output:
1 2 3 4 5 6 9
π See also π
beginβ returns an iterator to the beginningcbeginβ (public member function) (C++11)endcendβ returns an iterator to the end of a container or array (C++11) (function template) (C++14)
muah π sign-off time: source is http://cppreference.com, date is 2024.06.10, and the page tag is std::set::e...::set::cend(3). bye bestie π«Ά
π¦ 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