std::ranges::View,std::ranges::enable_view,std::ranges::view_base (3) - Linux Manuals

std::ranges::View,std::ranges::enable_view,std::ranges::view_base: std::ranges::View,std::ranges::enable_view,std::ranges::view_base

NAME

std::ranges::View,std::ranges::enable_view,std::ranges::view_base - std::ranges::View,std::ranges::enable_view,std::ranges::view_base

Synopsis


Defined in header <ranges>
template<class T> (1)
concept View = Range<T> && Semiregular<T> && enable_view<T>;
template<class T> (2)
inline constexpr bool enable_view = /*see description*/ ;
struct view_base { }; (3)


1) The View concept specifies the requirements of a Range type that has constant time copy, move, and assignment operations (e.g. a pair of iterators, or a generator Range that creates its elements on-demand. Notably, the standard library containers are Ranges, but not Views)
2) The enable_view variable template is used to indicate that whether a Range is a View, as follows:
For a type T, the default value of enable_view<T> is:


* If DerivedFrom<T, view_base> is true, enable_view<T> is true.
* Otherwise, if T is a specialization of class template std::initializer_list, std::set, std::multiset, std::unordered_set, std::unordered_multiset, std::match_results, enable_view<T> is false
* Otherwise, if both T and const T model Range and iter_reference_t<iterator_t<T>> is not the same type as iter_reference_t<iterator_t<const T>>, enable_view<T> is false. (in other words, deep constness implies element ownership, shallow constness implies reference (view) semantics)
* Otherwise, enable_view<T> is true.


3) Deriving from view_base enables Range types to model View.

Notes


Users may derive from view_base or specialize enable_view to true for types which model View, and specialize enable_view to false for types which do not.