std::ranges..._view::begin(3)
π
std::ranges..._view::begin(3) π
okay so bestie, this is the C++ Standard Libary manual page β yes, that spelling is straight from the header and weβre keeping it π. The header title is std::ranges..._view::begin(3), and the NAME section is literally std::ranges::common_view::begin twice. Iconic repetition, no notes.
πΈ NAME πΈ
std::ranges::common_view::begin β std::ranges::common_view::begin
Thatβs the whole NAME, fr fr. The manual name folded up top is C++ Standard Libary, section 3.
β¨ Synopsis β¨
constexpr auto begin() requires (!__simple_view<V>); (1) (since C++20)
constexpr auto begin() const requires range<const V>; (2) (since C++20)
Both overloads are marked since C++20. The synopsis is giving overload energy, and weβre obsessed.
- Returns an iterator to the first element of the
common_view, that is:ranges::begin(base_), if bothranges::random_access_range<V>andranges::sized_range<V>are satisfied,std::common_iterator<ranges::iterator_t<V>, ranges::sentinel_t<V>>(ranges::begin(base_))otherwise.
Here base_ (the name is for exposition only purposes) is the underlying view.
- Same as (1), but
Vis const-qualified.
π§ Parameters π§
None. Not a single parameter. Periodt.
π Return value π
An iterator to the beginning of the underlying view.
π Example π
Run this code, bestie β itβs right here, untouched:
// Run this code
#include <iostream>
#include <numeric>
#include <ranges>
#include <string_view>
int main()
{
constexpr auto common = std::views::iota(1)
| std::views::take(3)
| std::views::common
;
for (int i{}; int e : common)
std::cout << (i++ ? " + " : "") << e;
std::cout << " = " << std::accumulate(common.begin(), common.end(),
0) << '\n';
}
π Output π
1 + 2 + 3 = 6
π Defect reports π
The following behavior-changing defect reports were applied retroactively to previously published C++ standards. Retroactive fixes are lowkey iconic.
LWG 4012β Applied to:C++20; Behavior as published: non-const overload missed simple-view check; Correct behavior: added.
π¦ See also π¦
end(C++20) β returns an iterator to the end (public member function)ranges::begin(C++20) β returns an iterator to the beginning of a range (customization point object)ranges::end(C++20) β returns a sentinel indicating the end of a range (customization point object)
π xoxo, bestie π β source: http://cppreference.com; version/date: 2024.06.10; footer title: std::ranges..._view::begin(3). Stay iconic, and hydrate before you compile π
π
π¦ 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