deduction guides for std::ranges::split_view
From cppreference.com
< cpp | ranges | split view
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Ranges library
(C++23)(C++23)
(C++26)(C++26)
(C++23)(C++23)
(C++26)(C++26)
(C++26)(C++26)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
(C++23)(C++23)
template< class R, class P >
(1)
(since C++20)
split_view( R&&, P&& )
template< ranges::input_range R >
(2)
(since C++20)
split_view( R&&, ranges::range_value_t <R> )
These deduction guides are provided for split_view to allow deduction from a range and a delimiter.
1) The delimiter is a range of elements.
2) The delimiter is a single element.
[edit] Example
Run this code
#include <ranges> #include <string_view> #include <type_traits> using std::operator""sv; int main() { std::ranges::split_view w1{"a::b::c"sv, "::"sv}; static_assert(std::is_same_v < decltype(w1), std::ranges::split_view <std::string_view, std::string_view >>); std::ranges::split_view w2{"x,y,z"sv, ','}; static_assert(std::is_same_v < decltype(w2), std::ranges::split_view <std::string_view, std::ranges::single_view <char>>>); }