Skip to content

Commit

Permalink
Rename Optional26 to Optional
Browse files Browse the repository at this point in the history
Remove the target ship date from the name of the project.
  • Loading branch information
steve-downey committed Jan 18, 2025
1 parent b383b1a commit f0a223d
Show file tree
Hide file tree
Showing 35 changed files with 1,223 additions and 1,223 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
- name: Install
run: |
set -x
cmake --install .build --config RelWithDebInfo --component beman_optional26_development --verbose
cmake --install .build --config RelWithDebInfo --component beman_optional_development --verbose
- name: CMake Gcov Build
if: matrix.config.coverage
run: |
Expand All @@ -132,5 +132,5 @@ jobs:
if: matrix.config.coverage
uses: coverallsapp/github-action@main
with:
file: ${{runner.workspace}}/optional26/.build/coverage.json
file: ${{runner.workspace}}/optional/.build/coverage.json
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cff-version: 1.0.0
message: "If you use this software, please cite it as below."
title: "beman.optional26"
url: "https://github.com/bemanproject/optional26"
title: "beman.optional"
url: "https://github.com/bemanproject/optional"
40 changes: 20 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

cmake_minimum_required(VERSION 3.27)

project(beman_optional26 VERSION 0.0.0 LANGUAGES CXX)
project(beman_optional VERSION 0.0.0 LANGUAGES CXX)

# Includes
include(CTest)
Expand All @@ -13,13 +13,13 @@ include(FetchContent)
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)

option(
OPTIONAL26_ENABLE_TESTING
OPTIONAL_ENABLE_TESTING
"Enable building tests and test infrastructure"
${PROJECT_IS_TOP_LEVEL}
)

# Build the tests if enabled via the option OPTIONAL26_ENABLE_TESTING
if(OPTIONAL26_ENABLE_TESTING)
# Build the tests if enabled via the option OPTIONAL_ENABLE_TESTING
if(OPTIONAL_ENABLE_TESTING)
# Fetch GoogleTest
FetchContent_Declare(
googletest
Expand All @@ -33,29 +33,29 @@ endif()

set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)

# Create the library target and named header set for beman_optional26
add_library(beman_optional26 INTERFACE)
# Create the library target and named header set for beman_optional
add_library(beman_optional INTERFACE)
target_sources(
beman_optional26
PUBLIC FILE_SET beman_optional26_headers TYPE HEADERS BASE_DIRS include
beman_optional
PUBLIC FILE_SET beman_optional_headers TYPE HEADERS BASE_DIRS include
)

if(OPTIONAL26_ENABLE_TESTING)
# Create the library target and named header set for testing beman_optional26
if(OPTIONAL_ENABLE_TESTING)
# Create the library target and named header set for testing beman_optional
# and mark the set private
add_executable(beman_optional26_test)
add_executable(beman_optional_test)
target_sources(
beman_optional26_test
beman_optional_test
PRIVATE
FILE_SET beman_optional26_test_headers
FILE_SET beman_optional_test_headers
TYPE HEADERS
BASE_DIRS src
)

add_subdirectory(src/beman/optional26/tests)
add_subdirectory(src/beman/optional/tests)
endif()

add_subdirectory(include/beman/optional26)
add_subdirectory(include/beman/optional)

add_subdirectory(examples)

Expand All @@ -65,17 +65,17 @@ include(CMakePackageConfigHelpers)
set(cmakeModulesDir cmake/beman)
configure_package_config_file(
cmake/Config.cmake.in
BemanOptional26Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
BemanOptionalConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional/
PATH_VARS cmakeModulesDir
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/BemanOptional26Config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
COMPONENT beman_optional26_development
FILES ${CMAKE_CURRENT_BINARY_DIR}/BemanOptionalConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional/
COMPONENT beman_optional_development
)

# Coverage
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ compile: $(_build_path)/CMakeCache.txt ## Compile the project
cmake --build $(_build_path) --config $(CONFIG) --target all -- -k 0

install: $(_build_path)/CMakeCache.txt compile ## Install the project
cmake --install $(_build_path) --config $(CONFIG) --component beman_optional26_development --verbose
cmake --install $(_build_path) --config $(CONFIG) --component beman_optional_development --verbose

ctest: $(_build_path)/CMakeCache.txt ## Run CTest on current build
cd $(_build_path) && ctest --output-on-failure -C $(CONFIG)
Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# beman.optional26: C++26 Extensions for std::optional
# beman.optional: C++26 Extensions for std::optional

<!--
SPDX-License-Identifier: 2.0 license with LLVM exceptions
-->

<!-- markdownlint-disable -->
<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)
<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)
<!-- markdownlint-enable -->

This repository implements `std::optional` extensions targeting C++26. The `beman.optional26` library aims to evaluate
This repository implements `std::optional` extensions targeting C++26. The `beman.optional` library aims to evaluate
the stability, the usability, and the performance of these proposed changes before they are officially adopted by WG21
into the C++ Working Draft. Additionally, it allows developers to use these new features before they are implemented in
major standard library compilers.
Expand Down Expand Up @@ -44,18 +44,18 @@ Full runable examples can be found in `examples/` - please check [./examples/REA
The next code snippet shows optional range support added in [Give *std::optional* Range Support(P3168R2)](https://wg21.link/P3168R2):

```cpp
#include <beman/optional26/optional.hpp>
#include <beman/optional/optional.hpp>
...

// Example from P3168R2: basic range loop over C++26 optional.

beman::optional26::optional<int> empty_opt{};
beman::optional::optional<int> empty_opt{};
for ([[maybe_unused]] const auto& i : empty_opt) {
// Should not see this in console.
std::cout << "\"for each loop\" over C++26 optional: empty_opt\n";
}

beman::optional26::optional<int> opt{26};
beman::optional::optional<int> opt{26};
for (const auto& i : opt) {
// Should see this in console.
std::cout << "\"for each loop\" over C++26 optional: opt = " << i << "\n";
Expand All @@ -71,13 +71,13 @@ The next code snippet shows optional reference support added in [`std::optional<
(P2988R5)](https://wg21.link/P2988R5):

```cpp
#include <beman/optional26/optional.hpp>
#include <beman/optional/optional.hpp>
...

{
// Empty optional example.
std::optional<int> std_empty_opt;
beman::optional26::optional<int> beman_empty_opt;
beman::optional::optional<int> beman_empty_opt;
assert(!std_empty_opt.has_value() &&
!beman_empty_opt.has_value()); // or assert(!std_empty_opt && !beman_empty_opt);
std::cout << "std_vs_beman: .has_value() matches?: "
Expand All @@ -87,7 +87,7 @@ The next code snippet shows optional reference support added in [`std::optional<
{
// Optional with value example.
std::optional<int> std_opt = 26;
beman::optional26::optional<int> beman_opt = 26;
beman::optional::optional<int> beman_opt = 26;
assert(std_opt.has_value() && beman_opt.has_value()); // or assert(std_opt && beman_opt);
assert(std_opt.value() == beman_opt.value()); // or assert(*std_opt == *beman_opt);
std::cout << "std_vs_beman: .value() matches?: " << (std_opt.value() == beman_opt.value() ? "yes" : "no")
Expand Down Expand Up @@ -135,7 +135,7 @@ Full set of supported toolchains can be found in [.github/workflows/ci.yml](.git
#### Preset CMake Flows

This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will
work, producing a static `beman_optional26` library, ready to package:
work, producing a static `beman_optional` library, ready to package:

```shell
# List available preset configurations:
Expand Down Expand Up @@ -185,14 +185,14 @@ This should build and run the tests with GCC 14 with the address and undefined b
CI current build and test flows:

```shell
# Configure build: default build production code + tests (OPTIONAL26_ENABLE_TESTING=ON by default).
# Configure build: default build production code + tests (OPTIONAL_ENABLE_TESTING=ON by default).
$ cmake -G "Ninja Multi-Config" \
-DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \
-DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \
-B .build -S .
-- The CXX compiler identification is Clang 19.0.0
...
-- Build files have been written to: /path/to/optional26/.build
-- Build files have been written to: /path/to/optional/.build

# Build.
$ cmake --build .build --config Asan --target all -- -k 0
Expand All @@ -201,8 +201,8 @@ $ cmake --build .build --config Asan --target all -- -k 0

# Run tests.
$ ctest --build-config Asan --output-on-failure --test-dir .build
Internal ctest changing into directory: /path/to/optional26/.build
Test project /path/to/optional26/.build
Internal ctest changing into directory: /path/to/optional/.build
Test project /path/to/optional/.build
...
100% tests passed, 0 tests failed out of 82

Expand All @@ -211,18 +211,18 @@ Total Test time (real) = 0.67 sec

##### Build Production, but Skip Tests

By default, we build and run tests. You can provide `-DOPTIONAL26_ENABLE_TESTING=OFF` and completely disable building tests:
By default, we build and run tests. You can provide `-DOPTIONAL_ENABLE_TESTING=OFF` and completely disable building tests:

```shell
# Configure build: build production code, skip tests (OPTIONAL26_ENABLE_TESTING=OFF).
# Configure build: build production code, skip tests (OPTIONAL_ENABLE_TESTING=OFF).
$ cmake -G "Ninja Multi-Config" \
-DCMAKE_CONFIGURATION_TYPES="RelWithDebInfo;Asan" \
-DCMAKE_TOOLCHAIN_FILE=etc/clang-19-toolchain.cmake \
-DOPTIONAL26_ENABLE_TESTING=OFF \
-DOPTIONAL_ENABLE_TESTING=OFF \
-B .build -S .
-- The CXX compiler identification is Clang 19.0.0
...
-- Build files have been written to: /path/to/optional26/.build
-- Build files have been written to: /path/to/optional/.build

# Build.
$ cmake --build .build --config Asan --target all -- -k 0
Expand All @@ -231,8 +231,8 @@ $ cmake --build .build --config Asan --target all -- -k 0

# Check that tests are not built/installed.
$ ctest --build-config Asan --output-on-failure --test-dir .build
Internal ctest changing into directory: /path/to/beman.optional26/.build
Test project /path/to/beman.optional26/.build
Internal ctest changing into directory: /path/to/beman.optional/.build
Test project /path/to/beman.optional/.build
No tests were found!!!
```

Expand Down
2 changes: 1 addition & 1 deletion cmake/gcovr.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gcov-parallel = yes
html-theme = github.dark-blue
html-self-contained = yes
print-summary = yes
filter = .*/beman/optional26/.*
filter = .*/beman/optional/.*
exclude = .*\.t\.cpp
coveralls = coverage.json
coveralls-pretty = yes
2 changes: 1 addition & 1 deletion docs/debug-ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Stage Job ID Job name Workflow name Workflow file Events
0 build ${{ matrix.config.name }} CI Tests ci.yml pull_request,push

# Run all CI jobs
optional26 $ sudo act -P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:full-24.04 --container-architecture linux/amd64 push
optional $ sudo act -P ubuntu-24.04=ghcr.io/catthehacker/ubuntu:full-24.04 --container-architecture linux/amd64 push
[CI Tests/Ubuntu Clang 18-2] 🚀 Start image=ghcr.io/catthehacker/ubuntu:full-24.04
[CI Tests/Ubuntu Clang 19-3] 🚀 Start image=ghcr.io/catthehacker/ubuntu:full-24.04
[CI Tests/Ubuntu Clang 17-1] 🚀 Start image=ghcr.io/catthehacker/ubuntu:full-24.04
Expand Down
6 changes: 3 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

set(BEMAN_OPTIONAL26_LIBRARY "beman_optional26")
set(BEMAN_OPTIONAL_LIBRARY "beman_optional")

include(GNUInstallDirs)

Expand All @@ -25,14 +25,14 @@ foreach(example ${EXAMPLES})
target_sources(${example} PRIVATE ${example}.cpp)

# Link example with the library.
target_link_libraries(${example} "${BEMAN_OPTIONAL26_LIBRARY}")
target_link_libraries(${example} "${BEMAN_OPTIONAL_LIBRARY}")

# Install .
install(
TARGETS
${example}
COMPONENT
beman_optional26_examples
beman_optional_examples
DESTINATION
${CMAKE_INSTALL_BINDIR}
)
Expand Down
6 changes: 3 additions & 3 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Examples for beman.optional26
# Examples for beman.optional

<!--
SPDX-License-Identifier: 2.0 license with LLVM exceptions
-->

List of usage examples for `beman.optional26`.
List of usage examples for `beman.optional`.

## Samples

Check basic `beman.optional26` library usages:
Check basic `beman.optional` library usages:

* local [./sample.cpp](./sample.cpp) or [sample.cpp@Compiler Explorer](https://godbolt.org/z/47vGje65x)
* local [./std_vs_beman.cpp](./std_vs_beman.cpp) or [std_vs_beman.cpp@Compiler Explorer](https://godbolt.org/z/ds5MvfGe6)
Expand Down
16 changes: 8 additions & 8 deletions examples/concept_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <optional>
#include <beman/optional26/optional.hpp>
#include <beman/optional/optional.hpp>

#include <concepts>

Expand Down Expand Up @@ -85,13 +85,13 @@ int main() {
}

{
// beman::optional26::optional meets range concepts.
test_concepts_enabled(beman::optional26::optional<int>{});
test_concepts_enabled(beman::optional26::optional<int*>{});
test_concepts_enabled(beman::optional26::optional<test::empty>{});
test_concepts_enabled(beman::optional26::optional<test::no_default_ctor>{});
test_concepts_enabled(beman::optional26::optional<test::base>{});
test_concepts_enabled(beman::optional26::optional<test::derived>{});
// beman::optional::optional meets range concepts.
test_concepts_enabled(beman::optional::optional<int>{});
test_concepts_enabled(beman::optional::optional<int*>{});
test_concepts_enabled(beman::optional::optional<test::empty>{});
test_concepts_enabled(beman::optional::optional<test::no_default_ctor>{});
test_concepts_enabled(beman::optional::optional<test::base>{});
test_concepts_enabled(beman::optional::optional<test::derived>{});
}

return 0;
Expand Down
12 changes: 6 additions & 6 deletions examples/optional_ref.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// examples/optional_ref.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/optional26/optional.hpp>
#include <beman/optional/optional.hpp>

#include <string>

Expand Down Expand Up @@ -33,12 +33,12 @@ namespace std26 {
// After C++26 with P2988R5, the code would look like this.
// Using directly optional to represent optional references.

beman::optional26::optional<Cat&> find_cat(std::string) { return {}; }
beman::optional::optional<Cat&> find_cat(std::string) { return {}; }

beman::optional26::optional<Cat&> do_it(Cat& cat) { return {cat}; }
beman::optional::optional<Cat&> do_it(Cat& cat) { return {cat}; }

beman::optional26::optional<Cat&> api() {
beman::optional26::optional<Cat&> cat = find_cat("Fido");
beman::optional::optional<Cat&> api() {
beman::optional::optional<Cat&> cat = find_cat("Fido");
return cat.and_then(do_it);
}

Expand All @@ -47,7 +47,7 @@ beman::optional26::optional<Cat&> api() {
int main() {
// Example from P2988R5: optional reference.
[[maybe_unused]] Cat* old_cat = std17::api();
[[maybe_unused]] beman::optional26::optional<Cat&> new_cat = std26::api();
[[maybe_unused]] beman::optional::optional<Cat&> new_cat = std26::api();

return 0;
}
Expand Down
Loading

0 comments on commit f0a223d

Please sign in to comment.