Difference between revisions of "cpp/ranges/view"
From cppreference.com
(→Notes: -) |
(Change definition of view according to http://eel.is/c++draft/range.view#concept:view from Nov 2020) |
||
Line 6: | Line 6: | ||
{{dcl|num=1|1= | {{dcl|num=1|1= | ||
template<class T> | template<class T> | ||
− | concept view = ranges::range<T> && std:: | + | concept view = ranges::range<T> && std::movable<T> && std::default_initializable<T> && ranges::enable_view<T>; |
}} | }} | ||
{{dcl|num=2|1= | {{dcl|num=2|1= |
Revision as of 11:07, 30 November 2020
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 that 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
.