Defined in header <ranges> | ||
---|---|---|
template<class T> concept View = Range<T> && Semiregular<T> && enable_view<T>; | (1) | |
template<class T> inline constexpr bool enable_view = /*see description*/ ; | (2) | |
struct view_base { }; | (3) |
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)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:
DerivedFrom<T, view_base>
is true
, enable_view<T>
is true
. 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
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) enable_view<T>
is true
.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.
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/ranges/View