std::ranges...ter-iterator(3)
β¨ NAME β¨
std::ranges::chunk_view::outer-iterator β okay so this is the manual-name bestie, and the page is std::ranges...ter-iterator(3) from the C++ Standard Libary (yes, βLibaryβ is literally how the manual spells it π). Say hi to std::ranges::chunk_view::outer-iterator β and yes, the NAME line is literally std::ranges::chunk_view::outer-iterator twice with a dash, because the manual is extra like that. Itβs the exposition-only star of the show, bestie. π
πΈ Synopsis πΈ
class /*outer-iterator*/ (since C++23)
(exposition only*)
Itβs the return type of chunk_view::begin if V models input_range. Thatβs the whole vibe check, no cap. π
π Member types π
iterator_conceptβstd::input_iterator_tagdifference_typeβranges::range_difference_t<V>
π¦ Data members π¦
parent_(private) β a pointer to the"parent object"of typeranges::chunk_view*(exposition-only member object*).
π Member functions π
constructor(C++23)β constructs an iterator; public member function.operator=(C++23)β move assigns another iterator; public member function.operator*(C++23)β accesses the element; public member function.operator++(C++23)β increments the iterator; public member function.
π₯ Non-member functions π₯
operator==(C++23)β compares the iterator with default sentinel; function.operator-(C++23)β calculates the number of chunks remaining; function.
π Nested classes π
value_type(C++23)β the value type of/*output-iterator*/; public member class.
π Example π
// Run this code β copy-paste bestie, itβs right here:
// Run this code
#include <iostream>
#include <iterator>
#include <ranges>
#include <sstream>
int main()
{
const std::string source{"ABCDEFGHIJ"};
auto letters = std::istringstream{source};
auto chunks = std::ranges::istream_view<char>(letters)
| std::views::chunk(4);
for (auto outer_iter = chunks.begin(); outer_iter != std::default_sentinel;
++outer_iter)
{
auto chunk = *outer_iter; // chunk is an object of type
// chunk_view::outer_iterator::value_type
std::cout << '[';
for (auto inner_iter = chunk.begin(); inner_iter != std::default_sentinel;
++inner_iter)
std::cout << *inner_iter;
std::cout << "] ";
}
std::cout << '\n';
// The same output using range-for loops
auto letters2 = std::istringstream{source};
auto chunks2 = std::ranges::istream_view<char>(letters2)
| std::views::chunk(4);
for (auto chunk : chunks2)
{
std::cout << '[';
for (auto ch : chunk)
std::cout << ch;
std::cout << "] ";
}
std::cout << '\n';
}
π Output π
[ABCD] [EFGH] [IJ]
[ABCD] [EFGH] [IJ]
π References π
- C++23 standard (
ISO/IEC 14882:2023):26.7.28.3Classchunk_view::outer-iterator[range.chunk.outer.iter]
π See also π
No extra entries listed here, bestie β the footer info is the little sign-off below. π
Sign-off time: source/version is http://cppreference.com, date is 2024.06.10, and the page title is std::ranges...ter-iterator(3). Thatβs the whole manual page, and it ate. π
β¨
π¦ 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