Skip to content

Commit 0327196

Browse files
committed
[doc] update docs
1 parent 390bdfb commit 0327196

File tree

3 files changed

+40
-31
lines changed

3 files changed

+40
-31
lines changed

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
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.
44
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.
55

6+
67
## 🪞 Differences and similarities to std::ranges
78

89
```cpp
9-
auto adapted_range = original_range | range_adaptor_object | range_adaptor_object2;
10+
auto range_adaptor = underlying_range | range_adaptor_object | range_adaptor_object2;
1011
```
1112

12-
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.
1516

1617

1718
### ⌨️ Summary for the casual C++ programmer
@@ -22,6 +23,7 @@ To achieve this, we are sometimes stricter about what the `original_range` needs
2223
* [Simpler types](./docs/simpler_types.md) and better error messages (at least we are trying :sweat_smile:).
2324
* Less confusion: you don't need to understand what a "view" is, because it is irrelevant for this library.
2425

26+
2527
### 🤓 Summary for the Ranges nerd
2628

2729
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
3638
* This results in simpler types, fewer nested template instantiations, and avoids lots of special cases in the multi-pass implementations.
3739

3840

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-
4941
## 🗒️ Library facts
5042

5143
* Easy to use: header-only and no dependencies
5244
* License: Apache with LLVM exception[^boost]
5345
* Compilers: GCC≥11 or Clang≥17
5446
* 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]
5649

5750
[^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`.
5851

5952
[^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.
6053

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+
6166
## 👪 Credits
6267

6368
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).

docs/getting_started.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
The usage patterns of this library are almost identical to the standard library.
44

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()`.
68

7-
## Quickstart
9+
## Capturing the underlying range
810

911
```cpp
1012
/* temporaries */
@@ -18,13 +20,13 @@ auto rad1 = std::move(vec1) | radr::take(2); // this library
1820

1921
/* refer to existing borrowed range */
2022
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
2325

2426
/* refer to existing container */
2527
std::vector vec2{1, 2, 3};
2628
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!
2830
```
2931
3032
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*.
4951
Our range adaptors can be created on any of these three categories, and will result in an adapted range of the same
5052
category, except that `std::ref()`-ing a container leads to a borrowed range (see the last example above).
5153
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".
5355
We do not use the term "view" and the formal and informal definitions of "view" and "viewable range" are irrelevant for this library.

docs/implementation_status.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This library is a **work-in-progress**.
44
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.
55
The latter will likely change at some point.
66

7+
78
## Range adaptor classes
89

910

@@ -16,6 +17,7 @@ The latter will likely change at some point.
1617
There are no distinct type templates per adaptor (like e.g. `std::ranges::transform_view` for `std::views::transform` in the standard library).
1718
Instead all range adaptor objects in this library (see below) return a specialisation of one of the above type templates.
1819

20+
1921
## Range adaptor objects
2022

2123
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.
4143
| `radr::transform(fn)` | C++20 | | `std::views::transform` | C++20 | |
4244
| `radr::values` | C++20 | | `std::views::values` | C++20 | |
4345

44-
4546
All range adaptors from this library are available in C++20, although `radr::as_rvalue` behaves slightly different between modes.
4647

4748
[^diff]: These range adaptors have relevant differences between `std::` and `radr::`. Usually the names have been chosen differently to highlight this.
4849

50+
4951
## Range factory objects
5052

51-
| Range factories | Equivalent in `std::` | Remarks |
52-
|-------------------------------|-------------------------|------------------------------------------------------|
53-
| `radr::empty<T>` | `std::views::empty` | |
54-
| `radr::iota(val[, bound])` | `std::views::iota` | multi-pass version of iota |
55-
| `radr::iota_sp(val[, bound])` | `std::views::iota` | single-pass version of iota |
56-
| `radr::istream<Val>` | `std::views::istream` | |
57-
| `radr::istream<Val>` | `std::views::istream` | |
58-
| `radr::repeat(val[, bound])` | `std::views::repeat` | allows indirect storage and static bounds |
59-
| `radr::single(val)` | `std::views::single` | allows indirect storage |
53+
| Range factories (objects) | C++XY | | Equivalent in `std::` | C++XY | Remarks |
54+
|-------------------------------|-------|-|-------------------------|-----------|-------------------------------------------|
55+
| `radr::empty<T>` | C++20 | | `std::views::empty` | C++20 | |
56+
| `radr::iota(val[, bound])` | C++20 | | `std::views::iota` | C++20 | multi-pass version of iota |
57+
| `radr::iota_sp(val[, bound])` | C++20 | | `std::views::iota` | C++20 | single-pass version of iota |
58+
| `radr::istream<Val>` | C++20 | | `std::views::istream` | C++20 | |
59+
| `radr::repeat(val[, bound])` | C++20 | | `std::views::repeat` | **C++23** | allows indirect storage and static bounds |
60+
| `radr::single(val)` | C++20 | | `std::views::single` | C++20 | allows indirect storage |
61+
6062

6163
## Notable functions
6264

0 commit comments

Comments
 (0)