std::ranges...face::front(3)
β¨ NAME β¨
Okay so this is the manual page for std::ranges::view_interface::front β yes, the name and the title are literally the same, no cap. It comes from the C++ Standard Libary (spelled exactly like that in the header, bestie π).
std::ranges::view_interface::front β std::ranges::view_interface::front
πΈ Synopsis πΈ
Hereβs the signature situation, and yes the requires clauses are doing main-character work:
constexpr decltype(auto) front() (1) (since C++20)
requires ranges::forward_range<D>;
constexpr decltype(auto) front() const (2) (since C++20)
requires ranges::forward_range<const D>;
The default implementation of the front() 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 the operator* of the iterator type.
- Let
derivedbestatic_cast<D&>(*this). Equivalent toreturn *ranges::begin(derived);. The behavior is undefined ifempty()is true (i.e. the beginning iterator compares equal to the sentinel), even if the iterator obtained in the same way is dereferenceable. - Same as (1), except that
derivedisstatic_cast<const D&>(*this).
π Parameters π
(none) β literally no parameters, bestie. Not a single one.
π Return value π
The first element in the view. Thatβs it. Iconic.
π§ Notes π§
In C++20, no type derived from std::ranges::view_interface in the standard library provides their own front() member function. Almost all of these types use the default implementation.
A notable exception is std::ranges::basic_istream_view. For it never satisfies forward_range, the view cannot use the inherited front().
The inherited front() member function is available for std::ranges::empty_view, but a call to it always results in undefined behavior. So likeβ¦ available, but not cute. π
π Example π
This section is incomplete.
Reason: no example
Not me showing up to the example section and itβs empty ππ
π₯ See also π₯
begincbeginβ returns an iterator to the beginning of a container or array (C++11) (function template) (C++14)ranges::beginβ returns an iterator to the beginning of a range (C++20) (customization point object)ranges::cbeginβ returns an iterator to the beginning of a read-only range (C++20) (customization point object)
π Category π
- Todo no example
Catch you later, bestie π«Άπ this cutie came from http://cppreference.com, version/date 2024.06.10, page std::ranges...face::front(3). Periodt. β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms