Skip to content

Commit fa022cf

Browse files
committed
Update readme
1 parent f82d58b commit fa022cf

1 file changed

Lines changed: 15 additions & 74 deletions

File tree

README.md

Lines changed: 15 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
77
<!-- markdownlint-disable-next-line line-length -->
88
![Library Status](https://raw.githubusercontent.com/bemanproject/beman/refs/heads/main/images/badges/beman_badge-beman_library_under_development.svg) ![Continuous Integration Tests](https://github.com/steve-downey/expected/actions/workflows/ci_tests.yml/badge.svg) ![Lint Check (pre-commit)](https://github.com/steve-downey/expected/actions/workflows/pre-commit-check.yml/badge.svg) [![Coverage](https://coveralls.io/repos/github/steve-downey/expected/badge.svg?branch=main)](https://coveralls.io/github/steve-downey/expected?branch=main) ![Standard Target](https://github.com/bemanproject/beman/blob/main/images/badges/cpp29.svg) [![Compiler Explorer Example](https://img.shields.io/badge/Try%20it%20on%20Compiler%20Explorer-grey?logo=compilerexplorer&logoColor=67c52a)](https://www.example.com)
99

10-
`beman.expected` is a minimal C++ library conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md).
11-
This can be used as a template for those intending to write Beman libraries.
12-
It may also find use as a minimal and modern C++ project structure.
10+
`beman.expected` is a C++ library implementing the std::expected specification conforming to [The Beman Standard](https://github.com/bemanproject/beman/blob/main/docs/beman_standard.md).
1311

14-
**Implements**: `std::identity` proposed in [Standard Library Concepts (PnnnnRr)](https://wg21.link/PnnnnRr).
12+
**Implements**: `std::expected` proposed in [Expected over References (PnnnnRr)](https://wg21.link/PnnnnRr).
1513

1614
**Status**: [Under development and not yet ready for production use.](https://github.com/bemanproject/beman/blob/main/docs/beman_library_maturity_model.md#under-development-and-not-yet-ready-for-production-use)
1715

@@ -21,66 +19,6 @@ It may also find use as a minimal and modern C++ project structure.
2119

2220
## Usage
2321

24-
`std::identity` is a function object type whose `operator()` returns its argument unchanged.
25-
`std::identity` serves as the default projection in constrained algorithms.
26-
Its direct usage is usually not needed.
27-
28-
### Usage: default projection in constrained algorithms
29-
30-
The following code snippet illustrates how we can achieve a default projection using `beman::expected::identity`:
31-
32-
```cpp
33-
#include <beman/expected/identity.hpp>
34-
35-
namespace exe = beman::expected;
36-
37-
// Class with a pair of values.
38-
struct Pair
39-
{
40-
int n;
41-
std::string s;
42-
43-
// Output the pair in the form {n, s}.
44-
// Used by the range-printer if no custom projection is provided (default: identity projection).
45-
friend std::ostream &operator<<(std::ostream &os, const Pair &p)
46-
{
47-
return os << "Pair" << '{' << p.n << ", " << p.s << '}';
48-
}
49-
};
50-
51-
// A range-printer that can print projected (modified) elements of a range.
52-
// All the elements of the range are printed in the form {element1, element2, ...}.
53-
// e.g., pairs with identity: Pair{1, one}, Pair{2, two}, Pair{3, three}
54-
// e.g., pairs with custom projection: {1:one, 2:two, 3:three}
55-
template <std::ranges::input_range R,
56-
typename Projection>
57-
void print(const std::string_view rem, R &&range, Projection projection = exe::identity>)
58-
{
59-
std::cout << rem << '{';
60-
std::ranges::for_each(
61-
range,
62-
[O = 0](const auto &o) mutable
63-
{ std::cout << (O++ ? ", " : "") << o; },
64-
projection);
65-
std::cout << "}\n";
66-
};
67-
68-
int main()
69-
{
70-
// A vector of pairs to print.
71-
const std::vector<Pair> pairs = {
72-
{1, "one"},
73-
{2, "two"},
74-
{3, "three"},
75-
};
76-
77-
// Print the pairs using the default projection.
78-
print("\tpairs with beman: ", pairs);
79-
80-
return 0;
81-
}
82-
83-
```
8422

8523
Full runnable examples can be found in [`examples/`](examples/).
8624

@@ -159,9 +97,11 @@ For more documentation on GitHub codespaces, please see
15997
<details>
16098
<summary> For Linux </summary>
16199
162-
Beman libraries require [recent versions of CMake](#build-environment),
163-
we recommend downloading CMake directly from [CMake's website](https://cmake.org/download/)
164-
or installing it with the [Kitware apt library](https://apt.kitware.com/).
100+
Beman libraries require [recent versions of CMake](#build-environment).
101+
We recommend one of:
102+
- downloading CMake directly from [CMake's website](https://cmake.org/download/)
103+
- installing it with the [Kitware apt library](https://apt.kitware.com/).
104+
- installing for the project using [Astral's uv](https://docs.astral.sh/uv/) and PyPI.
165105
166106
A [supported compiler](#supported-platforms) should be available from your package manager.
167107
@@ -328,7 +268,7 @@ To use `beman.expected` in your C++ project,
328268
include an appropriate `beman.expected` header from your source code.
329269

330270
```c++
331-
#include <beman/expected/identity.hpp>
271+
#include <beman/expected/expected.hpp>
332272
```
333273

334274
> [!NOTE]
@@ -371,13 +311,14 @@ This will generate the following directory structure at `/opt/beman`.
371311
```txt
372312
/opt/beman
373313
├── include
374-
│ └── beman
375-
│ └── expected
376-
│ └── identity.hpp
314+
│   └── beman
315+
│   └── expected
316+
│   ├── bad_expected_access.hpp
317+
│   ├── expected.hpp
318+
│   └── unexpected.hpp
377319
└── lib
378320
└── cmake
379321
└── beman.expected
380-
├── beman.expected-config-version.cmake
381322
├── beman.expected-config.cmake
382-
── beman.expected-targets.cmake
383-
```
323+
── beman.expected-config-version.cmake
324+
└── beman.expected-targets.cmake```

0 commit comments

Comments
 (0)