1- # beman.optional26 : C++26 Extensions for std::optional
1+ # beman.optional : C++26 Extensions for std::optional
22
33<!--
44SPDX-License-Identifier: 2.0 license with LLVM exceptions
55-->
66
77<!-- markdownlint-disable -->
8- <img src =" https://github.com/bemanproject/beman/blob/main/images/logos/beman_logo-beman_library_production_ready_api_may_undergo_changes.png " style =" width :5% ; height :auto ;" > ![ CI Tests] ( https://github.com/bemanproject/optional26 /actions/workflows/ci.yml/badge.svg ) [ ![ Coverage] ( https://coveralls.io/repos/github/bemanproject/optional26 /badge.svg?branch=main )] ( https://coveralls.io/github/bemanproject/optional26 ?branch=main )
8+ <img src =" https://github.com/bemanproject/beman/blob/main/images/logos/beman_logo-beman_library_production_ready_api_may_undergo_changes.png " style =" width :5% ; height :auto ;" > ![ CI Tests] ( https://github.com/bemanproject/optional /actions/workflows/ci.yml/badge.svg ) [ ![ Coverage] ( https://coveralls.io/repos/github/bemanproject/optional /badge.svg?branch=main )] ( https://coveralls.io/github/bemanproject/optional ?branch=main )
99<!-- markdownlint-enable -->
1010
11- This repository implements ` std::optional ` extensions targeting C++26. The ` beman.optional26 ` library aims to evaluate
11+ This repository implements ` std::optional ` extensions targeting C++26. The ` beman.optional ` library aims to evaluate
1212the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21
1313into the C++ Working Draft. Additionally, it allows developers to use these new features before they are implemented in
1414major standard library compilers.
@@ -44,18 +44,18 @@ Full runable examples can be found in `examples/` - please check [./examples/REA
4444The next code snippet shows optional range support added in [ Give * std::optional* Range Support(P3168R2)] ( https://wg21.link/P3168R2 ) :
4545
4646``` cpp
47- #include < beman/optional26 /optional.hpp>
47+ #include < beman/optional /optional.hpp>
4848...
4949
5050// Example from P3168R2: basic range loop over C++26 optional.
5151
52- beman::optional26 ::optional<int > empty_opt{};
52+ beman::optional ::optional<int > empty_opt{};
5353for ([[maybe_unused]] const auto & i : empty_opt) {
5454 // Should not see this in console.
5555 std::cout << "\"for each loop\" over C++26 optional: empty_opt\n";
5656}
5757
58- beman::optional26 ::optional<int > opt{26};
58+ beman::optional ::optional<int > opt{26};
5959for (const auto& i : opt) {
6060 // Should see this in console.
6161 std::cout << "\" for each loop\" over C++26 optional: opt = " << i << "\n";
@@ -71,13 +71,13 @@ The next code snippet shows optional reference support added in [`std::optional<
7171(P2988R5)] ( https://wg21.link/P2988R5 ) :
7272
7373``` cpp
74- #include < beman/optional26 /optional.hpp>
74+ #include < beman/optional /optional.hpp>
7575...
7676
7777{
7878 // Empty optional example.
7979 std::optional<int> std_empty_opt;
80- beman::optional26 ::optional<int> beman_empty_opt;
80+ beman::optional ::optional<int> beman_empty_opt;
8181 assert (!std_empty_opt.has_value() &&
8282 !beman_empty_opt.has_value()); // or assert(!std_empty_opt && !beman_empty_opt);
8383 std::cout << "std_vs_beman: .has_value() matches?: "
@@ -87,7 +87,7 @@ The next code snippet shows optional reference support added in [`std::optional<
8787{
8888 // Optional with value example.
8989 std::optional<int> std_opt = 26;
90- beman::optional26 ::optional<int> beman_opt = 26;
90+ beman::optional ::optional<int> beman_opt = 26;
9191 assert (std_opt.has_value() && beman_opt.has_value()); // or assert(std_opt && beman_opt);
9292 assert(std_opt.value() == beman_opt.value()); // or assert(* std_opt == * beman_opt);
9393 std::cout << "std_vs_beman: .value() matches?: " << (std_opt.value() == beman_opt.value() ? "yes" : "no")
@@ -135,7 +135,7 @@ Full set of supported toolchains can be found in [.github/workflows/ci.yml](.git
135135#### Preset CMake Flows
136136
137137This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will
138- work, producing a static ` beman_optional26 ` library, ready to package:
138+ work, producing a static ` beman_optional ` library, ready to package:
139139
140140``` shell
141141# List available preset configurations:
@@ -185,14 +185,14 @@ This should build and run the tests with GCC 14 with the address and undefined b
185185CI current build and test flows:
186186
187187``` shell
188- # Configure build: default build production code + tests (OPTIONAL26_ENABLE_TESTING =ON by default).
188+ # Configure build: default build production code + tests (OPTIONAL_ENABLE_TESTING =ON by default).
189189$ cmake -G " Ninja Multi-Config" \
190190 -DCMAKE_CONFIGURATION_TYPES=" RelWithDebInfo;Asan" \
191191 -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \
192192 -B .build -S .
193193-- The CXX compiler identification is Clang 19.0.0
194194...
195- -- Build files have been written to: /path/to/optional26 /.build
195+ -- Build files have been written to: /path/to/optional /.build
196196
197197# Build.
198198$ cmake --build .build --config Asan --target all -- -k 0
@@ -201,8 +201,8 @@ $ cmake --build .build --config Asan --target all -- -k 0
201201
202202# Run tests.
203203$ ctest --build-config Asan --output-on-failure --test-dir .build
204- Internal ctest changing into directory: /path/to/optional26 /.build
205- Test project /path/to/optional26 /.build
204+ Internal ctest changing into directory: /path/to/optional /.build
205+ Test project /path/to/optional /.build
206206...
207207100% tests passed, 0 tests failed out of 82
208208
@@ -211,18 +211,18 @@ Total Test time (real) = 0.67 sec
211211
212212##### Build Production, but Skip Tests
213213
214- By default, we build and run tests. You can provide ` -DOPTIONAL26_ENABLE_TESTING =OFF ` and completely disable building tests:
214+ By default, we build and run tests. You can provide ` -DOPTIONAL_ENABLE_TESTING =OFF ` and completely disable building tests:
215215
216216``` shell
217- # Configure build: build production code, skip tests (OPTIONAL26_ENABLE_TESTING =OFF).
217+ # Configure build: build production code, skip tests (OPTIONAL_ENABLE_TESTING =OFF).
218218$ cmake -G " Ninja Multi-Config" \
219219 -DCMAKE_CONFIGURATION_TYPES=" RelWithDebInfo;Asan" \
220220 -DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \
221- -DOPTIONAL26_ENABLE_TESTING =OFF \
221+ -DOPTIONAL_ENABLE_TESTING =OFF \
222222 -B .build -S .
223223-- The CXX compiler identification is Clang 19.0.0
224224...
225- -- Build files have been written to: /path/to/optional26 /.build
225+ -- Build files have been written to: /path/to/optional /.build
226226
227227# Build.
228228$ cmake --build .build --config Asan --target all -- -k 0
@@ -231,8 +231,8 @@ $ cmake --build .build --config Asan --target all -- -k 0
231231
232232# Check that tests are not built/installed.
233233$ ctest --build-config Asan --output-on-failure --test-dir .build
234- Internal ctest changing into directory: /path/to/beman.optional26 /.build
235- Test project /path/to/beman.optional26 /.build
234+ Internal ctest changing into directory: /path/to/beman.optional /.build
235+ Test project /path/to/beman.optional /.build
236236No tests were found!!!
237237```
238238
0 commit comments