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

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

✨ NAME ✨

okay so bestie, welcome to the std::ranges..._view::base(3) page from the C++ Standard Library πŸ’– this one is literally named:

std::ranges::lazy_split_view::base β€” std::ranges::lazy_split_view::base

like yes, it said it twice and honestly? iconic behavior πŸ‘‘


🌸 Synopsis 🌸

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

So there are two overloads, bestie:

  • (1) β€” constexpr V base() const& requires std::copy_constructible<V>; and it's since C++20 ✨
  • (2) β€” constexpr V base() &&; and it's also since C++20 πŸ’…

Both of them return a copy of the underlying view 🫢

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

πŸŽ€ Parameters πŸŽ€

none. not a single one. zero. the void is giving minimalism 🌈


πŸ’– Return value πŸ’–

a copy of the underlying view πŸ’«


πŸ¦‹ Example πŸ¦‹

run this code, bestie:

#include <iostream>
#include <ranges>
#include <string_view>

void print(std::string_view rem, auto const& r, std::string_view post =
       "\n") {
    for (std::cout << rem; auto const& e : r)
        std::cout << e;
    std::cout << post;
}

int main()
{
    constexpr std::string_view keywords{ "this,..throw,..true,..try,.."
       };
    constexpr std::string_view pattern{",.."};
    constexpr std::ranges::lazy_split_view lazy_split_view{keywords,
       pattern};
    print("base() = [", lazy_split_view.base(), "]\n"
          "substrings: ");
    for (auto const& split: lazy_split_view)
        print("[", split, "] ");
}

⭐ Output ⭐

base() = [this,..throw,..true,..try,..]
substrings: [this] [throw] [true] [try] []

ate and left no crumbs πŸ˜­πŸ’…


πŸ‘‘ See also πŸ‘‘

  • base β€” returns a copy of the underlying (adapted) view, (C++20), and it's a public member function of std::ranges::split_view<V,Pattern> πŸ¦‹

that's the whole page, bestie β€” no cap, every detail is here and it's living its main character era 🌸✨

source/version + date, as promised: cppreference.com Β· 2024.06.10 Β· and the manual is std::ranges..._view::base(3) πŸŽ€πŸ’–πŸ«Ά

πŸ“¦ where this page comes from