std::ranges::view, std::ranges::enable_view, std::ranges::view_base
From cppreference.com
< cpp | ranges
Revision as of 00:30, 28 December 2020 by 2a01:6500:a042:f979:b421:6745:96df:2601 (Talk)
Defined in header <ranges>
|
||
template<class T> concept view = ranges::range<T> && std::movable<T> && std::default_initializable<T> && ranges::enable_view<T>; |
(1) | |
template<class T> inline constexpr bool enable_view = std::derived_from<T, view_base>; |
(2) | |
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 range
s, but not view
s)2) The enable_view variable template is used to indicate whether a
range
is a view. By default, a type is considered a view if it is publicly and unambiguously derived from view_base. Users may specialize
enable_view
to true for cv-unqualified program-defined types which model view
, and false for types which do not. Such specializations must be usable in constant expressions and have type const bool
.