| ||||||||||||||||||||||
| Range primitives | |||||||
| |||||||
| Range concepts | |||||||||||||||||||
| |||||||||||||||||||
| Range factories | |||||||||
| |||||||||
| Range adaptors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Helper items | |||||||||||||||||
| |||||||||||||||||
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
(C++26) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class/*outer-iterator*/ | (since C++23) (exposition only*) | |
The return type ofchunk_view::begin ifV modelsinput_range.
Contents |
| Member type | Definition |
iterator_concept | std::input_iterator_tag |
difference_type | ranges::range_difference_t<V> |
| Member object | Definition |
parent_(private) | A pointer to the "parent object" of typeranges::chunk_view* (exposition-only member object*) |
(C++23) | constructs an iterator (public member function) |
(C++23) | move assigns another iterator (public member function) |
(C++23) | accesses the element (public member function) |
(C++23) | increments the iterator (public member function) |
(C++23) | compares the iterator withdefault sentinel (function) |
(C++23) | calculates the number of chunks remaining (function) |
(C++23) | the value type of/*output-iterator*/ (public member class) |
#include <iostream>#include <iterator>#include <ranges>#include <sstream> int main(){conststd::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_typestd::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 loopsauto 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]