All the libraries defined below are included in the header <ranger> and <iterator>.
std::ranges::empty_view
Argument-dependent lookup makes it possible to use operators defined in a different namespace. For Example:
If we use ::
std::cout << "Hello\n"; // There is no operator<< in global namespace, but ADL examines std namespace because the left argument is in \std and finds std::operator<<(std::ostream&, const char*)
operator<<(std::cout, "Hello\n"); // same, using function call notation.
Empty_view are functions that are not visible to ordinary lookup, and can only be found by argument-dependent lookup when std::ranges::empty_view<T> is an associated class of the arguments.
Example Code
#include <ranges>
int main() { std::ranges::empty_view<int> a; static_assert(std::ranges::empty(a)); static_assert(0 == a.size()); }std::ranges::enable_view
The enable_view variable template is used to indicate that whether a Range is a View.
(definition of Views has been done in my first article of ranges libraries.)A type is considered a view if it is unambiguously derived from view_base by default.
For a For a type T, the default value of enable_view<T> is:If Deriiif DerivedFrom<T, view_base> is true, enable_view<T> is true.std::ranges::filter_view
- base_ and pred_ are default initialisers.
- base_ := std::move(base) and pred_ = std::move(pred).
- Initializes base_ with view::all(std::forward<R>(r)) and initializes pred_ with std::%u200Bmove(pred).
Its Parameters are:
- pred - predicate to filter elements.
- r - range to filter.
Comments