You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-10Lines changed: 31 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,22 +25,43 @@ The README itself is licesed with CC0 1.0 Universal. Copy the contents and incor
25
25
26
26
## Examples
27
27
28
-
Full runable examples can be found in `examples/` - please check [./examples/README.md](./examples/README.md).
28
+
Full runable examples can be found in `examples/` - please check [./examples/README.md](./examples/README.md) for building the code on local setup or on Compiler Explorer.
29
29
30
-
### TODO - first example
30
+
### Repetead Chars Iterator
31
31
32
-
The next code snippet shows iterator interface support added in [`std::iterator_interface` (P2727R4)](https://wg21.link/P2727R4):
32
+
The next code snippet shows iterator interface support added in [`std::iterator_interface` (P2727R)](https://wg21.link/P2727R4): define a random access iterator that iterates over a sequence of characters repeated indefinitely.
33
33
34
34
```cpp
35
-
TODO
35
+
// Create a repeated_chars_iterator that iterates over the sequence "foo" repeated indefinitely:
36
+
// "foofoofoofoofoofoo...". Will actually extract a prefix of the sequence and insert it into a std::string.
37
+
constexprconst std::string_view target = "foo";
38
+
constexprconstauto len = 7; // Number of extracted characters from the sequence.
39
+
40
+
// Create iterators that iterate over the sequence "foofoofoofoofoofoo...".
41
+
repeated_chars_iterator it_first(target.data(), target.size(), 0); // target.size() == 3 is the length of "foo", 0 is this iterator's position.
42
+
repeated_chars_iterator it_last(target.data(), target.size(), len); // Same as above, but now the iterator's position is 7.
The next code snippet shows iterator interface support added in [`std::iterator_interface` (P2727R4)](https://wg21.link/P2727R4):
52
+
The next code snippet shows iterator interface support added in [`std::iterator_interface` (P2727R4)](https://wg21.link/P2727R4): define a forward iterator that iterates over a sequence of integers, skipping those that do not satisfy a predicate.
41
53
42
54
```cpp
43
-
TODO
55
+
// Create a filtered_int_iterator that iterates over the sequence {1, 2, 3, 4, 10, 11, 101, 200, 0},
56
+
// skipping odd numbers. 0 is not skipped, so it will be the last element in the sequence.
0 commit comments