std::ranges..._view::base(3)

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

πŸ’… std::ranges..._view::base(3) πŸ’…

okay so welcome to the C++ Standard Libary manual page for std::ranges::common_view::base β€” yes bestie, that's the manual name, folded in right here instead of copy-pasting the header line like a NPC. This page is lowkey all about std::ranges::common_view::base, and it's giving very specific C++20 energy. πŸ¦‹


🌸 NAME 🌸

std::ranges::common_view::base - std::ranges::common_view::base


✨ Synopsis ✨

This bad boy returns a copy of the underlying view β€” that's the whole plot. The synopsis is giving two overloads, both since C++20:

          constexpr V base() const& requires std::copy_constructible<V>; (1)
       (since C++20)
          constexpr V base() &&;                                         (2)
       (since C++20)

So real talk:

  1. (1) copy constructs the result from the underlying view.
  2. (2) move constructs the result from the underlying view.

slay. πŸ’–


🌼 Parameters 🌼

(none) β€” literally zero arguments, bestie. Nada. The parameter list is empty and thriving. 🫢


πŸ’– Return value πŸ’–

A copy of the underlying view. That's it. That's the tea. πŸ‘‘


πŸŽ€ Example πŸŽ€

       // Run this code

        #include <iostream>
        #include <ranges>
        #include <string>

        int main()
        {
            std::string str { "C++20" };
            auto view = std::views::common(str);

            std::string copy_of_str = view.base();
            std::cout << "copy of str: [" << copy_of_str << "]\n";
            std::cout << "view.base(): [" << view.base() << "]\n";

            std::string move_str = std::move(view.base());
            std::cout << "moved str:   [" << move_str << "]\n";
            std::cout << "view.base(): [" << view.base() << "]\n"; //
       unspecified
        }
bestie notice the last line is marked // unspecified β€” that means exactly what it says: unspecified. Do not build your whole personality on that final output, okay? πŸ˜­πŸ’€

🌈 Possible output 🌈

        copy of str: [C++20]
        view.base(): [C++20]
        moved str:   [C++20]
        view.base(): []

okay that's the whole page, periodt! This manual page came from http://cppreference.com, dated 2024.06.10, and its footer tag is std::ranges..._view::base(3) β€” catch you in the next one, bestie πŸ’–πŸŽ€

πŸ“¦ where this page comes from