std::flat_set::begin,(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

Okay so you’re on the std::flat_set::begin,(3) page from the C++ Standard Libary β€” and yes, the header spells it β€œLibary” like that, iconic typo behavior πŸ’…. The NAME is std::flat_set::begin, β€” and the original NAME line also repeats std::flat_set::begin, after the dash, fr fr.

✨ Synopsis ✨

Three signatures, all since C++23, and here they are exactly:

iterator begin() noexcept;              (1) (since C++23)
const_iterator begin() const noexcept;  (2) (since C++23)
const_iterator cbegin() const noexcept; (3) (since C++23)

Returns an iterator to the first element of the flat_set.

If the flat_set is empty, the returned iterator will be equal to end().

There’s also a diagram vibe referenced as range-begin-end.svg.

😌 Parameters 😌

(none) β€” literally no parameters, bestie.

🫢 Return value 🫢

Iterator to the first element.

πŸ’… Complexity πŸ’…

Constant. That’s the whole mood.

πŸ‘‘ 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. No sneaky edits through these iterators, periodt. 🚫

🌈 Example 🌈

// Run this code

#include <algorithm>
#include <flat_set>
#include <iostream>

int main()
{
    std::flat_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 πŸ¦‹

  • end β€” returns an iterator to the end
  • cend β€” (public member function)
  • begin
  • cbegin β€” returns an iterator to the beginning of a container or array
  • (C++11)
  • (C++14)
  • (function template)

Source: http://cppreference.com Β· version/date: 2024.06.10 Β· page: std::flat_set::begin,(3) β€” mwah πŸ’‹

πŸ“¦ where this page comes from