std::flat_map::keys(3)

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

✨ NAME ✨

okay so this page is std::flat_map::keys β€” literally std::flat_map::keys β€” from the C++ Standard Libary manual, and it’s here to hand you the keys container, bestie. πŸ’–


🌸 Synopsis 🌸

const key_container_type& keys() const noexcept;  (since C++23)

Return a constant reference to the adapted keys container. Equivalent to return c.keys;. ✨

πŸŽ€ Parameters πŸŽ€

(none) β€” no params, no stress, we love that for us. 🫢

πŸ’œ Return value πŸ’œ

The underlying keys container. That’s the whole vibe. πŸ‘‘

πŸ”₯ Complexity πŸ”₯

Constant. periodt. ⭐

πŸ¦‹ Example πŸ¦‹

Run this code πŸ‘‡

        #include <flat_map>
        #include <print>
        #include <type_traits>
        #include <vector>

        int main()
        {
            std::flat_map<int, double> adaptor{{1, 1.1}, {2, 2.2}, {3, 3.3}};

            // The default keys container is std::vector:
            static_assert(std::is_same_v<decltype(adaptor.keys()), const
       std::vector<int>&>);

            std::println("{}", adaptor.keys());
        }

Output πŸ’¬

        [1, 2, 3]

🌈 See also 🌈

  • values β€” direct access to the underlying values container (public member function). πŸ’…

made with πŸ’– from http://cppreference.com, version/date 2024.06.10, on the std::flat_map::keys(3) page β€” byeee πŸŽ€

πŸ“¦ where this page comes from