std::flat_multimap::end,(3)

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

πŸ’– NAME πŸ’–

Okay bestie, this is the std::flat_multimap::end page β€” page std::flat_multimap::end,(3) β€” from the C++ Standard Library manual. The NAME line is literally:

std::flat_multimap::end, - std::flat_multimap::end,

Commas included. No, I'm not gaslighting you πŸ’….


🌸 Synopsis 🌸

All three overloads are noexcept, and all three are since C++23:

iterator end() noexcept;              (1) (since C++23)
const_iterator end() const noexcept;  (2) (since C++23)
const_iterator cend() const noexcept; (3) (since C++23)

So what does it do? It returns an iterator to the element following the last element of the flat_multimap. Periodt.

⚠️ That element is a placeholder, and attempting to access it results in undefined behavior. Not cute, not safe, do not.

The source also has a diagram named range-begin-end.svg right here β€” consider it mentioned so it doesn't get lost πŸ¦‹.


πŸŽ€ Parameters πŸŽ€

(none) β€” literally none, bestie. No arguments, no stress.


✨ Return value ✨

Iterator to the element following the last element.


πŸ¦‹ Complexity πŸ¦‹

Constant. O(1) energy, we love to see it ⭐.


🌈 Example 🌈

The source says // Run this code right before this block, so here's the example:

#include <iostream>
#include <flat_map>

int main()
{
    std::flat_multimap<int, int> map{{4, 13}, {9, 94}, {1, 19}, {4, 42}};

    for (auto it = map.cbegin(); it != map.cend(); ++it)
        std::cout << '[' << it->first << "] = " << it->second << '\n';

    // Unlike std::multimap's bidirectional iterators, the std::flat_multimap
    // iterators are random-access, so they can be used with the operator[]:
    auto it = map.cbegin();
    assert(it[1] == 19);
    assert(it[4] == 13);
    assert(it[4] == 42);
    assert(it[9] == 94);
}

⭐ Output ⭐

[1] = 19
[4] = 13
[4] = 42
[9] = 94

πŸ‘‘ See also πŸ‘‘

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

Source/version: http://cppreference.com β€’ date: 2024.06.10 β€’ page: std::flat_multimap::end,(3). Bye bestie, go slay those iterators πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from