deductiongu..._split_view(3)
okay bestie, you opened the deductionguidesforstd::ranges::lazy_split_view page π
β the manual name is C++ Standard Libary, and the header label is deductiongu..._split_view(3). This whole page is about the deduction guides for std::ranges::lazy_split_view, and they exist so you can deduce from a range and a delimiter. periodt β¨
π NAME π
deductionguidesforstd::ranges::lazy_split_view β deductionguidesforstd::ranges::lazy_split_view π«Ά
β¨ Synopsis β¨
Both guides are since C++20, no cap. Here's the signature block, exactly as printed:
template< class R, class P >
lazy_split_view( R&&, P&& )
(1) (since C++20)
-> lazy_split_view<views::all_t<R>, views::all_t<P>>;
template< ranges::input_range R >
lazy_split_view( R&&, ranges::range_value_t<R> )
-> lazy_split_view<views::all_t<R>,
(2) (since C++20)
ranges::single_view<ranges::range_value_t<R>>>;
These deduction guides are provided for lazy_split_view to allow deduction from a range and a delimiter. π
- The delimiter is a range of elements.
- The delimiter is a single element.
π Example π
run this code, bestie β it's giving compile-time type-deduction realness β¨
// Run this code
#include <ranges>
#include <string_view>
#include <type_traits>
using std::operator""sv;
int main()
{
std::ranges::lazy_split_view w1{"a::b::c"sv, "::"sv};
// type of w1 is lazy_split_view<string_view, string_view>:
static_assert(std::is_same_v<
decltype(w1),
std::ranges::lazy_split_view<
std::basic_string_view<char, std::char_traits<char>>,
std::basic_string_view<char, std::char_traits<char>>>>);
std::ranges::lazy_split_view w2{"x,y,z"sv, ','};
// type of w2 is lazy_split_view<string_view, single_view<char>>:
static_assert(std::is_same_v<
decltype(w2),
std::ranges::lazy_split_view<
std::basic_string_view<char, std::char_traits<char>>,
std::ranges::single_view<char>>>);
}
peep those static_asserts: w1 is deduced as lazy_split_view<string_view, string_view>, and w2 is deduced as lazy_split_view<string_view, single_view<char>> β the comments said it, not me π
mwah π bye bestie β this page's sign-off tea is source http://cppreference.com, dated 2024.06.10, with footer label deductiongu..._split_view(3). slay π«Ά
π¦ 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