Commit cd82335
authored
backport c++23 std::expected (#40)
After studied [0], [1] and [2], I'm inclined to backport [0] to
iceberg-cpp, the main reason is that [0] has exactly the same APIs as
std::expected, [1] provide some extra member functions like `map` and
`map_error`, [2] has different API names like `then` and `thenOrThrow`.
We want users to use iceberg::expected the same way as std::expected,
and we will replace iceberg::expected with std::expected when we decide
to move to c++23 some day, by backporting [0], we can facilitate a
smoother transition process.
We discussed about `Exceptions vs Expected` in #14, while backporting
[0], I had the feeling we shouldn't choose one over the other, we can
use both approaches effectively.
expected provide monadic operations like `and_then`, `transform`,
`or_else`, `transform_error`, let us do method chaining, which is a good
sign.
[0] https://github.com/zeus-cpp/expected
[1] https://github.com/TartanLlama/expected
[2] https://github.com/facebook/folly/blob/main/folly/Expected.h
[3] https://en.cppreference.com/w/cpp/utility/expected
---------
Signed-off-by: Junwang Zhao <[email protected]>1 parent 17c500a commit cd82335
File tree
7 files changed
+3026
-0
lines changed- .github
- workflows
- src/iceberg
- test/core
7 files changed
+3026
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments