std::ranges...ner-iterator(3)
okay bestie, this is the std::ranges::chunk_view::inner-iterator(3) page from the C++ Standard Libary manual β section 3, C++23, exposition-only energy, and she is lowkey iconic. Let's unpack her together π
β¨
π NAME π
std::ranges::chunk_view::inner-iterator β and yes, the page says std::ranges::chunk_view::inner-iterator again, so we're keeping both, periodt.
πΈ Synopsis πΈ
Code vibe:
class /*inner-iterator*/ (since C++23)
(exposition only*)
Translation for the group chat: this is the return type of chunk_view::outer-iterator::value_type::begin if V models input_range. That's the whole condition, no cap.
π Member types π
iterator_conceptβstd::input_iterator_tagdifference_typeβranges::range_difference_t<V>value_typeβranges::range_value_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)base(C++23) β returns an iterator to the current element (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 remained number of elements (function)iter_move(C++23) β casts the result of dereferencing the underlying iterator to its associated rvalue reference type (function)iter_swap(C++23) β swaps the objects pointed to by two underlying iterators (function)
π Example π
Run this code πββοΈπ¨:
#include <iostream>
#include <iterator>
#include <ranges>
#include <sstream>
int main()
{
auto letters = std::istringstream{"ABCDEFGHIJK"};
auto chunks = std::ranges::istream_view<char>(letters)
| std::views::chunk(4);
for (auto chunk : chunks)
{
// 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';
}
π Output π
[ABCD] [EFGH] [IJK]
π§ References π§
C++23 standard (ISO/IEC 14882:2023):26.7.28.5 Class chunk_view::inner-iterator [range.chunk.inner.iter]
π See also π
No extra SEE ALSO entries listed on this page, bestie β just the footer link situation below. π
Source/version: http://cppreference.com Β· date: 2024.06.10 Β· footer tag: std::ranges...ner-iterator(3) β that's the footer, and that's the whole vibe. bye bestie, go chunk responsibly π
π«Ά
π¦ 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