| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
| Member functions | ||||
(C++23) | ||||
(C++23) | ||||
front | ||||
constexpr decltype(auto) front() requiresranges::forward_range<D>; | (1) | (since C++20) |
constexpr decltype(auto) front()const requiresranges::forward_range<const D>; | (2) | (since C++20) |
The default implementation offront() member function returns the first element in the view of the derived type. Whether the element is returned by value or by reference depends on theoperator* of the iterator type.
derived bestatic_cast<D&>(*this). Equivalent toreturn*ranges::begin(derived);. The behavior is undefined ifempty() istrue (i.e. the beginning iterator compares equal to the sentinel), even if the iterator obtained in the same way is dereferenceable.derived isstatic_cast<const D&>(*this).Contents |
The first element in the view.
In C++20, no type derived fromstd::ranges::view_interface in the standard library provides their ownfront() member function. Almost all of these types use the default implementation.
A notable exception isstd::ranges::basic_istream_view. For it never satisfiesforward_range, the view cannot use the inheritedfront().
The inheritedfront() member function is available forstd::ranges::empty_view, but a call to it always results in undefined behavior.
| This section is incomplete Reason: no example |
(C++11)(C++14) | returns an iterator to the beginning of a container or array (function template)[edit] |
(C++20) | returns an iterator to the beginning of a range (customization point object)[edit] |
(C++20) | returns an iterator to the beginning of a read-only range (customization point object)[edit] |