std::ranges::View, std::ranges::enable_view, std::ranges::view_base
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) |
1) The
2) 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)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>istrue,enable_view<T>istrue. - Otherwise, if
Tis a specialization of class templatestd::initializer_list,std::set,std::multiset,std::unordered_set,std::unordered_multiset,std::match_results,enable_view<T>isfalse - Otherwise, if both
Tandconst TmodelRangeanditer_reference_t<iterator_t<T>>is not the same type asiter_reference_t<iterator_t<const T>>,enable_view<T>isfalse. (in other words, deep constness implies element ownership, shallow constness implies reference (view) semantics) - Otherwise,
enable_view<T>istrue.
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.
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/ranges/View