std::ranges::split_view<V,Pattern>::base
From cppreference.com
< cpp | ranges | split view
constexpr V base() const& requires std::copy_constructible<V>; |
(1) | (since C++20) |
constexpr V base() &&; |
(2) | (since C++20) |
Returns a copy of the underlying view base_
.
1) Copy constructs the result from the underlying view.
2) Move constructs the result from the underlying view.
Parameters
(none)
Return value
1) A copy of the underlying view.
2) A view move-constructed from the underlying view.
Example
A link to check the code: wandbox
Run this code
#include <iostream> #include <iomanip> #include <ranges> #include <string_view> int main() { constexpr std::string_view keywords{ "this throw true try typedef typeid" }; std::ranges::split_view split_view{ keywords, ' ' }; std::cout << "base() = " << std::quoted( split_view.base() ) << "\n" "substrings: "; for (std::string_view split: split_view) std::cout << quoted(split) << ' '; }
Output:
base() = "this throw true try typedef typeid" substrings: "this" "throw" "true" "try" "typedef" "typeid"
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3590 | C++20 | the const& overload additionally required validity of copy-assignment | constraints relaxed |
See also
(C++20) |
returns a copy of the underlying (adapted) view (public member function of std::ranges::lazy_split_view<V,Pattern> ) |