std::ranges..._view::base(3)
π 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)copy constructs the result from the underlying view.(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
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms