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
+20-15Lines changed: 20 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,15 +3,16 @@
3
3
This library explores an opinionated re-design of C++ Range Adaptors, commonly referred to as "views". It tries to reduce complexity in the conceptual space and provide a better, more consistent user experience.
4
4
At the same time, the usage patterns and naming remain close enough to the standard library to be used almost as a drop-in replacement.
The general pattern for creating adapted ranges is the same in our library and in the standard library.
13
-
However, we aim to establish clearer rules for what you can and cannot do with the `adapted_range`.
14
-
To achieve this, we are sometimes stricter about what the `original_range` needs to provide.
13
+
The general pattern for creating range adaptors is the same in our library and in the standard library.
14
+
However, we aim to establish clearer rules for what you can and cannot do with the `range_adaptor`.
15
+
To achieve this, we are sometimes stricter about what the `underlying_range` needs to provide.
15
16
16
17
17
18
### ⌨️ Summary for the casual C++ programmer
@@ -22,6 +23,7 @@ To achieve this, we are sometimes stricter about what the `original_range` needs
22
23
*[Simpler types](./docs/simpler_types.md) and better error messages (at least we are trying :sweat_smile:).
23
24
* Less confusion: you don't need to understand what a "view" is, because it is irrelevant for this library.
24
25
26
+
25
27
### 🤓 Summary for the Ranges nerd
26
28
27
29
This library [fundamentally differentiates between multi-pass and single-pass ranges](./docs/range_properties.md).
@@ -36,28 +38,31 @@ This library [fundamentally differentiates between multi-pass and single-pass ra
36
38
* This results in simpler types, fewer nested template instantiations, and avoids lots of special cases in the multi-pass implementations.
37
39
38
40
39
-
## 📖 Further reading
40
-
41
-
**Please have a look at the docs folder.**
42
-
In particular, you may be interested in:
43
-
44
-
*[Getting started](./docs/getting_started.md): short introduction on how to use this library and the terminology used in the documentation.
45
-
*[Implementation status](./docs/implementation_status.md): overview of which adaptors are already available.
46
-
*[Examples](./docs/examples.md): examples that illustrate standard library usage vs radr usage ("tony tables").
47
-
*[Trade-offs](./docs/tradeoffs.md): things to be aware before switching to this library.
48
-
49
41
## 🗒️ Library facts
50
42
51
43
* Easy to use: header-only and no dependencies
52
44
* License: Apache with LLVM exception[^boost]
53
45
* Compilers: GCC≥11 or Clang≥17
54
46
* Standard libraries: both libstdc++ and libc++ are tested.
55
-
* C++20 required.[^std]
47
+
* Progress: all std::views from C++20 are reimplemented and many later ones
48
+
* (Only) C++20 required.[^std]
56
49
57
50
[^boost]: The file `generator.hpp` is licensed under the Boost Software license. It is used only if your standard library does not provide `std::generator`.
58
51
59
52
[^std]: A bonus of using this library is getting access to the equivalent of C++23 and C++26 adaptors in a C++20-based codebase.
60
53
54
+
55
+
## 📖 Further reading
56
+
57
+
**Please have a look at the docs folder.**
58
+
In particular, you may be interested in:
59
+
60
+
*[Getting started](./docs/getting_started.md): short introduction on how to use this library and the terminology used in the documentation.
61
+
*[Implementation status](./docs/implementation_status.md): overview of which adaptors are already available.
62
+
*[Examples](./docs/examples.md): examples that illustrate standard library usage vs radr usage ("tony tables").
63
+
*[Trade-offs](./docs/tradeoffs.md): things to be aware before switching to this library.
64
+
65
+
61
66
## 👪 Credits
62
67
63
68
Not everything presented here is novel—in fact, many of the ideas are based on older "ranges" designs (e.g. old ISO papers, Boost ranges and old range-v3).
Copy file name to clipboardExpand all lines: docs/getting_started.md
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,11 @@
2
2
3
3
The usage patterns of this library are almost identical to the standard library.
4
4
5
-
Differences exist in handling some underlying ranges.
5
+
* Just replace `std::views::FOO` with `radr::FOO`; see below for slight differences in range capture.
6
+
* You can use all functions, algorithms and concepts from `std::ranges::` on our types.
7
+
* Optionally, you can use `radr::begin()` / `radr::end()` instead of `std::ranges::begin()` / `std::ranges::end()`.
6
8
7
-
## Quickstart
9
+
## Capturing the underlying range
8
10
9
11
```cpp
10
12
/* temporaries */
@@ -18,13 +20,13 @@ auto rad1 = std::move(vec1) | radr::take(2); // this library
18
20
19
21
/* refer to existing borrowed range */
20
22
std::span s = vec1;
21
-
auto vue2 = s | std::views::take(2); // standard library
22
-
auto rad2 = s | radr::take(2); // this library
23
+
auto vue2 = s | std::views::take(2); // standard library
24
+
auto rad2 = s | radr::take(2); // this library
23
25
24
26
/* refer to existing container */
25
27
std::vector vec2{1, 2, 3};
26
28
auto vue3 = vec2 | std::views::take(2); // standard library
27
-
auto rad3 = std::ref(vec2) | radr::take(2); // this library ← DIFFERENCE
29
+
auto rad3 = std::ref(vec2) | radr::take(2); // this library ← ONLY DIFFERENCE!
28
30
```
29
31
30
32
As you can see, only the syntax for creating an indirection is slightly different, i.e. when adapting an existing container, you need to explicitly state whether you want to `std::move()` or `std::ref()` it.
@@ -49,5 +51,5 @@ the *original range*.
49
51
Our range adaptors can be created on any of these three categories, and will result in an adapted range of the same
50
52
category, except that `std::ref()`-ing a container leads to a borrowed range (see the last example above).
51
53
52
-
In particular, it should be noted that *adapted ranges* are not a separate category and no range properties are specific to them; e.g. an adaptor on a `std::string_view` (a borrowed range) is also just a borrowed range—while an adaptor on a `std::vector` (first example above) is also just a "container".
54
+
In particular, it should be noted that *range adaptors* are not a separate category and no range properties are specific to them; e.g. an adaptor on a `std::string_view` (a borrowed range) is also just a borrowed range—while an adaptor on a `std::vector` (first example above) is also just a "container".
53
55
We do not use the term "view" and the formal and informal definitions of "view" and "viewable range" are irrelevant for this library.
Copy file name to clipboardExpand all lines: docs/implementation_status.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,7 @@ This library is a **work-in-progress**.
4
4
We try to stay close to standard library interfaces, but we neither promise full API compatibility with `std::ranges::` nor do we currently promise stability between releases of this library.
5
5
The latter will likely change at some point.
6
6
7
+
7
8
## Range adaptor classes
8
9
9
10
@@ -16,6 +17,7 @@ The latter will likely change at some point.
16
17
There are no distinct type templates per adaptor (like e.g. `std::ranges::transform_view` for `std::views::transform` in the standard library).
17
18
Instead all range adaptor objects in this library (see below) return a specialisation of one of the above type templates.
18
19
20
+
19
21
## Range adaptor objects
20
22
21
23
We plan to add equivalent objects for all standard library adaptors.
@@ -41,22 +43,22 @@ We plan to add equivalent objects for all standard library adaptors.
All range adaptors from this library are available in C++20, although `radr::as_rvalue` behaves slightly different between modes.
46
47
47
48
[^diff]: These range adaptors have relevant differences between `std::` and `radr::`. Usually the names have been chosen differently to highlight this.
48
49
50
+
49
51
## Range factory objects
50
52
51
-
| Range factories | Equivalent in `std::`|Remarks|
0 commit comments