std::flat_multimap::begin,(3)

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

🌸 std::flat_multimap::begin,(3) 🌸

hey bestie πŸ’– welcome to the std::flat_multimap::begin,(3) page from the C++ Standard Libary manual β€” yes, that exact spelling, she’s serving typo realness and we respect it.


NAME πŸ’…

std::flat_multimap::begin, β€” okay so the name is std::flat_multimap::begin,, and the page literally lists it again as std::flat_multimap::begin, after a -. The comma is part of the name. Do not come for her. πŸŽ€


Synopsis πŸ¦‹

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_multimap. ✨

If the flat_multimap is empty, the returned iterator will be equal to end(). no cap, that’s the vibe check.

Also range-begin-end.svg is literally just hanging out in this page. It’s a diagram, she’s iconic, we move. 🫢


Parameters 🌸

(none) β€” not a single parameter, bestie. not one. πŸ’€


Return value πŸ’–

Iterator to the first element. That’s the whole tea. πŸ‘‘


Complexity ⭐

Constant. periodt.


Example πŸ“

// Run this code

#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 πŸ‘€

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

okay bye bestie πŸ’‹ this page comes from http://cppreference.com, dated 2024.06.10, and the footer says std::flat_multimap::begin,(3) one more time for the people in the back. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from