diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 887526d..822fed9 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -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: |
diff --git a/CITATION.cff b/CITATION.cff
index 35c1d17..bd89450 100644
--- a/CITATION.cff
+++ b/CITATION.cff
@@ -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"
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5b4897d..d0cd921 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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)
@@ -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
@@ -33,29 +33,26 @@ 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
- PRIVATE
- FILE_SET beman_optional26_test_headers
- TYPE HEADERS
- BASE_DIRS src
+ beman_optional_test
+ PRIVATE 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)
@@ -65,17 +62,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
diff --git a/Makefile b/Makefile
index c98ab60..55fc1de 100755
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/README.md b/README.md
index 4456bb3..a8f41a5 100644
--- a/README.md
+++ b/README.md
@@ -1,14 +1,14 @@
-# beman.optional26: C++26 Extensions for std::optional
+# beman.optional: C++26 Extensions for std::optional
- ![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)
+ ![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)
-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.
@@ -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
+#include
...
// Example from P3168R2: basic range loop over C++26 optional.
-beman::optional26::optional empty_opt{};
+beman::optional::optional 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 opt{26};
+beman::optional::optional opt{26};
for (const auto& i : opt) {
// Should see this in console.
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<
(P2988R5)](https://wg21.link/P2988R5):
```cpp
-#include
+#include
...
{
// Empty optional example.
std::optional std_empty_opt;
- beman::optional26::optional beman_empty_opt;
+ beman::optional::optional 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?: "
@@ -87,7 +87,7 @@ The next code snippet shows optional reference support added in [`std::optional<
{
// Optional with value example.
std::optional std_opt = 26;
- beman::optional26::optional beman_opt = 26;
+ beman::optional::optional 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")
@@ -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:
@@ -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
@@ -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
@@ -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
@@ -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!!!
```
diff --git a/cmake/gcovr.cfg.in b/cmake/gcovr.cfg.in
index 6b2523d..91403c7 100644
--- a/cmake/gcovr.cfg.in
+++ b/cmake/gcovr.cfg.in
@@ -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
diff --git a/docs/debug-ci.md b/docs/debug-ci.md
index 0e92566..2d35cee 100644
--- a/docs/debug-ci.md
+++ b/docs/debug-ci.md
@@ -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
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index b94bbab..7932246 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -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)
@@ -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}
)
diff --git a/examples/README.md b/examples/README.md
index 4e50462..56e00ea 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -1,14 +1,14 @@
-# Examples for beman.optional26
+# Examples for beman.optional
-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)
diff --git a/examples/concept_checks.cpp b/examples/concept_checks.cpp
index 45025f7..2a12e03 100644
--- a/examples/concept_checks.cpp
+++ b/examples/concept_checks.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include
-#include
+#include
#include
@@ -85,13 +85,13 @@ int main() {
}
{
- // beman::optional26::optional meets range concepts.
- test_concepts_enabled(beman::optional26::optional{});
- test_concepts_enabled(beman::optional26::optional{});
- test_concepts_enabled(beman::optional26::optional{});
- test_concepts_enabled(beman::optional26::optional{});
- test_concepts_enabled(beman::optional26::optional{});
- test_concepts_enabled(beman::optional26::optional{});
+ // beman::optional::optional meets range concepts.
+ test_concepts_enabled(beman::optional::optional{});
+ test_concepts_enabled(beman::optional::optional{});
+ test_concepts_enabled(beman::optional::optional{});
+ test_concepts_enabled(beman::optional::optional{});
+ test_concepts_enabled(beman::optional::optional{});
+ test_concepts_enabled(beman::optional::optional{});
}
return 0;
diff --git a/examples/optional_ref.cpp b/examples/optional_ref.cpp
index 03aba83..4cb4966 100644
--- a/examples/optional_ref.cpp
+++ b/examples/optional_ref.cpp
@@ -1,7 +1,7 @@
// examples/optional_ref.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include
+#include
#include
@@ -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 find_cat(std::string) { return {}; }
+beman::optional::optional find_cat(std::string) { return {}; }
-beman::optional26::optional do_it(Cat& cat) { return {cat}; }
+beman::optional::optional do_it(Cat& cat) { return {cat}; }
-beman::optional26::optional api() {
- beman::optional26::optional cat = find_cat("Fido");
+beman::optional::optional api() {
+ beman::optional::optional cat = find_cat("Fido");
return cat.and_then(do_it);
}
@@ -46,8 +46,8 @@ beman::optional26::optional api() {
int main() {
// Example from P2988R5: optional reference.
- [[maybe_unused]] Cat* old_cat = std17::api();
- [[maybe_unused]] beman::optional26::optional new_cat = std26::api();
+ [[maybe_unused]] Cat* old_cat = std17::api();
+ [[maybe_unused]] beman::optional::optional new_cat = std26::api();
return 0;
}
diff --git a/examples/pythagorean_triples.cpp b/examples/pythagorean_triples.cpp
index e3b00aa..c5f4c6a 100644
--- a/examples/pythagorean_triples.cpp
+++ b/examples/pythagorean_triples.cpp
@@ -1,7 +1,7 @@
// examples/pythagorean_triples.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include
+#include
#include
#include
@@ -12,8 +12,8 @@
int main() {
// Example from P3168R2: generate an infinite sequence of Pythagorean triples.
// (x, y, z) is a Pythagorean triple if 1 <= x <= y <= z and x^2 + y^2 = z^2.
- constexpr auto yield_if = [](bool b, T x) -> beman::optional26::optional {
- return b ? beman::optional26::optional{std::move(x)} : beman::optional26::nullopt;
+ constexpr auto yield_if = [](bool b, T x) -> beman::optional::optional {
+ return b ? beman::optional::optional{std::move(x)} : beman::optional::nullopt;
};
constexpr auto and_then = [](T&& r, auto fun) {
return decltype(r)(r) | std::views::transform(std::move(fun)) | std::views::join;
diff --git a/examples/range_loop.cpp b/examples/range_loop.cpp
index c7dcc4e..96185e9 100644
--- a/examples/range_loop.cpp
+++ b/examples/range_loop.cpp
@@ -1,19 +1,19 @@
// examples/range_loop.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include
+#include
#include
int main() {
// Example from P3168R2: basic range loop over C++26 optional.
- beman::optional26::optional empty_opt{};
+ beman::optional::optional 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 opt{26};
+ beman::optional::optional opt{26};
for (const auto& i : opt) {
// Should see this in console.
std::cout << "\"for each loop\" over C++26 optional: opt = " << i << "\n";
diff --git a/examples/sample.cpp b/examples/sample.cpp
index e57ab8f..14536f7 100644
--- a/examples/sample.cpp
+++ b/examples/sample.cpp
@@ -1,16 +1,16 @@
// examples/sample.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include
+#include
#include
int main() {
- beman::optional26::optional empty_opt{};
+ beman::optional::optional empty_opt{};
if (!empty_opt) {
std::cout << "empty_opt is empty!\n";
}
- beman::optional26::optional opt{26};
+ beman::optional::optional opt{26};
if (opt) {
std::cout << "opt = " << *opt << "\n";
}
diff --git a/examples/std_vs_beman.cpp b/examples/std_vs_beman.cpp
index 69fab96..729d4fe 100644
--- a/examples/std_vs_beman.cpp
+++ b/examples/std_vs_beman.cpp
@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include
-#include
+#include
#include
#include
@@ -10,8 +10,8 @@
int main() {
{
// Empty optional example.
- std::optional std_empty_opt;
- beman::optional26::optional beman_empty_opt;
+ std::optional std_empty_opt;
+ beman::optional::optional 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?: "
@@ -20,8 +20,8 @@ int main() {
{
// Optional with value example.
- std::optional std_opt = 26;
- beman::optional26::optional beman_opt = 26;
+ std::optional std_opt = 26;
+ beman::optional::optional 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")
@@ -29,7 +29,7 @@ int main() {
}
// Note: std_empty_opt == beman_empty_opt and std_opt == beman_opt won't compile
- // (no implementation of operator== for std::optional and beman::optional26::optional).
+ // (no implementation of operator== for std::optional and beman::optional::optional).
return 0;
}
diff --git a/include/beman/optional/CMakeLists.txt b/include/beman/optional/CMakeLists.txt
new file mode 100644
index 0000000..57c7021
--- /dev/null
+++ b/include/beman/optional/CMakeLists.txt
@@ -0,0 +1,41 @@
+# include/beman/optional/CMakeLists.txt -*-cmake-*-
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+target_sources(
+ beman_optional
+ PUBLIC
+ FILE_SET beman_optional_headers
+ TYPE HEADERS
+ FILES
+ optional.hpp
+ detail/iterator.hpp
+ detail/stl_interfaces/config.hpp
+ detail/stl_interfaces/fwd.hpp
+ detail/stl_interfaces/iterator_interface.hpp
+)
+
+install(
+ TARGETS beman_optional
+ FILE_SET beman_optional_headers
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ COMPONENT beman_optional_development
+)
+
+install(
+ TARGETS beman_optional
+ EXPORT beman_optional_export
+ DESTINATION
+ ${CMAKE_INSTALL_LIBDIR}
+ FILE_SET beman_optional_headers
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
+ COMPONENT beman_optional_development
+)
+
+install(
+ EXPORT beman_optional_export
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional/
+ NAMESPACE Beman::Optional::
+ FILE beman_optional.cmake
+ EXPORT_LINK_INTERFACE_LIBRARIES
+ COMPONENT beman_optional_development
+)
diff --git a/include/beman/optional26/detail/iterator.hpp b/include/beman/optional/detail/iterator.hpp
similarity index 84%
rename from include/beman/optional26/detail/iterator.hpp
rename to include/beman/optional/detail/iterator.hpp
index 3683bc9..c7a99f7 100644
--- a/include/beman/optional26/detail/iterator.hpp
+++ b/include/beman/optional/detail/iterator.hpp
@@ -1,15 +1,15 @@
-// include/beman/optional26/detail/iterator.hpp -*-C++-*-
+// include/beman/optional/detail/iterator.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP
-#define BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP
+#ifndef BEMAN_OPTIONAL_DETAIL_ITERATOR_HPP
+#define BEMAN_OPTIONAL_DETAIL_ITERATOR_HPP
-#include
+#include
#include
#include
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
// Forward declaration.
template
@@ -19,7 +19,7 @@ struct contiguous_iterator;
// Current implementation based on P2727R4: std::iterator_interface.
template
using base_contiguous_iterator = stl_interfaces::iterator_interface<
-#if !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
+#if !BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
contiguous_iterator, // Required for P2727R4 to work with C++20/C++23. TODO: Do more experiments.
#endif
std::contiguous_iterator_tag,
@@ -62,6 +62,6 @@ struct contiguous_iterator : public base_contiguous_iterator {
T* m_current;
};
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
-#endif // BEMAN_OPTIONAL26_DETAIL_ITERATOR_HPP
+#endif // BEMAN_OPTIONAL_DETAIL_ITERATOR_HPP
diff --git a/include/beman/optional/detail/stl_interfaces/config.hpp b/include/beman/optional/detail/stl_interfaces/config.hpp
new file mode 100644
index 0000000..994b933
--- /dev/null
+++ b/include/beman/optional/detail/stl_interfaces/config.hpp
@@ -0,0 +1,49 @@
+// include/beman/optional/detail/stl_interfaces/config.hpp -*-C++-*-
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+// Copyright (C) 2020 T. Zachary Laine
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_CONFIG_HPP
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_CONFIG_HPP
+
+// Included for definition of __cpp_lib_concepts.
+#include
+
+#if defined(__cpp_lib_concepts) && defined(__cpp_lib_ranges) && \
+ !defined(BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DISABLE_CONCEPTS)
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS 1
+#else
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS 0
+#endif
+
+#if defined(__cpp_explicit_this_parameter) && BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS && \
+ !defined(BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DISABLE_DEDUCED_THIS)
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 1
+#else
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 0
+#endif
+
+// The inline namespaces v1, v2, and v3 represent C++14, C++20, and C++23 and
+// later, respectively. v1 is inline for standards before C++20, and v2 is
+// inline for C++20 and later. Note that this only applies to code for which
+// multiple vI namespace alternatives exist. For example, some instances of
+// the v1 namespace may still be inline, if there is no v2 version of its
+// contents.
+#if !BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
+#elif BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
+#else
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V3 inline namespace v3
+#endif
+
+#endif
diff --git a/include/beman/optional26/detail/stl_interfaces/fwd.hpp b/include/beman/optional/detail/stl_interfaces/fwd.hpp
similarity index 72%
rename from include/beman/optional26/detail/stl_interfaces/fwd.hpp
rename to include/beman/optional/detail/stl_interfaces/fwd.hpp
index ceb7a1e..536ac8a 100644
--- a/include/beman/optional26/detail/stl_interfaces/fwd.hpp
+++ b/include/beman/optional/detail/stl_interfaces/fwd.hpp
@@ -1,4 +1,4 @@
-// include/beman/optional26/detail/stl_interfaces/fwd.hpp -*-C++-*-
+// include/beman/optional/detail/stl_interfaces/fwd.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Copyright (C) 2019 T. Zachary Laine
@@ -6,36 +6,36 @@
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_FWD_HPP
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_FWD_HPP
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_FWD_HPP
-#include
+#include
-#if BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
+#if BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS
#include
#endif
#if defined(__cpp_lib_three_way_comparison)
#include
#endif
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
#if defined(_MSC_VER) || defined(__GNUC__) && __GNUC__ < 8
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NO_HIDDEN_FRIEND_CONSTEXPR
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NO_HIDDEN_FRIEND_CONSTEXPR
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR
#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR constexpr
#endif
#if defined(__GNUC__) && __GNUC__ < 9
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONCEPT concept bool
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_CONCEPT concept bool
#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONCEPT concept
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_CONCEPT concept
#endif
#endif
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
namespace stl_interfaces {
/** An enumeration used to indicate whether the underlying data have a
@@ -43,7 +43,7 @@ namespace stl_interfaces {
and `sequence_container_interface`. */
enum class element_layout : bool { discontiguous = false, contiguous = true };
-BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
+BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
namespace v1_dtl {
template
@@ -83,6 +83,6 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
} // namespace v1_dtl
}
} // namespace stl_interfaces
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
#endif
diff --git a/include/beman/optional26/detail/stl_interfaces/iterator_interface.hpp b/include/beman/optional/detail/stl_interfaces/iterator_interface.hpp
similarity index 93%
rename from include/beman/optional26/detail/stl_interfaces/iterator_interface.hpp
rename to include/beman/optional/detail/stl_interfaces/iterator_interface.hpp
index a0d97bd..5d439d2 100644
--- a/include/beman/optional26/detail/stl_interfaces/iterator_interface.hpp
+++ b/include/beman/optional/detail/stl_interfaces/iterator_interface.hpp
@@ -1,4 +1,4 @@
-// include/beman/optional26/detail/stl_interfaces/iterator_interface.hpp -*-C++-*-
+// include/beman/optional/detail/stl_interfaces/iterator_interface.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// Copyright (C) 2019 T. Zachary Laine
@@ -6,10 +6,10 @@
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_ITERATOR_INTERFACE_HPP
-#include
+#include
#include
#include
@@ -17,13 +17,13 @@
#include
#endif
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
namespace stl_interfaces {
/** A type for granting access to the private members of an iterator
derived from `iterator_interface`. */
struct access {
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
template
static constexpr auto base(D& d) noexcept -> decltype(d.base_reference()) {
@@ -44,7 +44,7 @@ struct access {
this template implies a copy or move of the underlying object of type
`T`. */
template
-#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
+#if defined(BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS
// clang-format off
requires std::is_object_v
#endif
@@ -127,11 +127,11 @@ common_diff(T lhs, U rhs) noexcept(noexcept(static_cast>(lhs) - s
} // namespace detail
} // namespace stl_interfaces
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
namespace stl_interfaces {
-BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
+BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
/** A CRTP template that one may derive from to make defining iterators
easier.
@@ -147,7 +147,7 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
typename Reference = ValueType&,
typename Pointer = ValueType*,
typename DifferenceType = std::ptrdiff_t
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
,
typename E = std::enable_if_t::value &&
std::is_same>::value>
@@ -187,13 +187,13 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
typename Reference,
typename Pointer,
typename DifferenceType
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
,
typename E
#endif
>
struct iterator_interface {
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifndef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
private:
constexpr Derived& derived() noexcept { return static_cast(*this); }
constexpr const Derived& derived() const noexcept { return static_cast(*this); }
@@ -279,8 +279,8 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
retval += i;
return retval;
}
- friend BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived operator+(difference_type i,
- Derived it) noexcept {
+ friend BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived operator+(difference_type i,
+ Derived it) noexcept {
return it + i;
}
@@ -320,7 +320,7 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
return access::base(derived()) - access::base(other);
}
- friend BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived
+ friend BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_HIDDEN_FRIEND_CONSTEXPR Derived
operator-(Derived it, difference_type i) noexcept {
Derived retval = it;
retval += -i;
@@ -416,13 +416,13 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 {
DifferenceType>;
}
} // namespace stl_interfaces
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
-#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
+#if defined(BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
namespace stl_interfaces {
-BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 {
+BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V2 {
namespace v2_dtl {
template
@@ -739,15 +739,15 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 {
DifferenceType>;
}
} // namespace stl_interfaces
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
#endif
-#if defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
+#if defined(BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN) || BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
-namespace beman::optional26::detail {
+namespace beman::optional::detail {
namespace stl_interfaces {
-BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 {
+BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_NAMESPACE_V3 {
// clang-format off
@@ -928,58 +928,58 @@ BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 {
iterator_interface, DifferenceType>;
}
} // namespace stl_interfaces
-} // namespace beman::optional26::detail
+} // namespace beman::optional::detail
#endif
-#ifdef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DOXYGEN
+#ifdef BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_DOXYGEN
/** `static_asserts` that type `type` models concept `concept_name`. This is
useful for checking that an iterator, view, etc. that you write using one
of the *`_interface` templates models the right C++ concept.
- For example: `BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(my_iter,
+ For example: `BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(my_iter,
std::input_iterator)`.
\note This macro expands to nothing when `__cpp_lib_concepts` is not
defined. */
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(type, concept_name)
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(type, concept_name)
/** `static_asserts` that the types of all typedefs in
`std::iterator_traits` match the remaining macro parameters. This
is useful for checking that an iterator you write using
`iterator_interface` has the correct iterator traits.
- For example: `BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS(my_iter,
+ For example: `BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS(my_iter,
std::input_iterator_tag, std::input_iterator, int, int &, int *, std::ptrdiff_t)`.
\note This macro ignores the `concept` parameter when `__cpp_lib_concepts`
is not defined. */
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
iter, category, concept, value_type, reference, pointer, difference_type)
#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(type, concept_name) \
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(type, concept_name) \
static_assert(concept_name, "");
-#if BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name) \
- BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(iter, concept_name)
+#if BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_USE_CONCEPTS
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name) \
+ BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_CONCEPT_IMPL(iter, concept_name)
#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name)
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_CONCEPT(iter, concept_name)
#endif
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_t, ref, ptr, diff_t) \
static_assert(std::is_same::value_type, value_t>::value, ""); \
static_assert(std::is_same::reference, ref>::value, ""); \
static_assert(std::is_same::pointer, ptr>::value, ""); \
static_assert(std::is_same::difference_type, diff_t>::value, "");
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
- iter, category, concept, value_type, reference, pointer, difference_type) \
- BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
+#define BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS( \
+ iter, category, concept, value_type, reference, pointer, difference_type) \
+ BEMAN_OPTIONAL_DETAIL_STL_INTERFACES_STATIC_ASSERT_ITERATOR_TRAITS_IMPL( \
iter, category, value_type, reference, pointer, difference_type)
#endif
diff --git a/include/beman/optional26/optional.hpp b/include/beman/optional/optional.hpp
similarity index 98%
rename from include/beman/optional26/optional.hpp
rename to include/beman/optional/optional.hpp
index 4d433d8..665cf52 100644
--- a/include/beman/optional26/optional.hpp
+++ b/include/beman/optional/optional.hpp
@@ -1,8 +1,8 @@
-// include/beman/optional26/optional.hpp -*-C++-*-
+// include/beman/optional/optional.hpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#ifndef BEMAN_OPTIONAL26_OPTIONAL_HPP
-#define BEMAN_OPTIONAL26_OPTIONAL_HPP
+#ifndef BEMAN_OPTIONAL_OPTIONAL_HPP
+#define BEMAN_OPTIONAL_OPTIONAL_HPP
#include
#include
@@ -14,9 +14,9 @@
#include
#include
-#include
+#include
-namespace beman::optional26 {
+namespace beman::optional {
namespace detail {
template
@@ -56,28 +56,28 @@ struct in_place_t {
inline constexpr in_place_t in_place{};
-} // namespace beman::optional26
+} // namespace beman::optional
-namespace beman::optional26 {
+namespace beman::optional {
template
class optional; // partially freestanding
-} // namespace beman::optional26
+} // namespace beman::optional
// Since P3168R2: Give std::optional Range Support.
template
-inline constexpr bool std::ranges::enable_view> = true;
+inline constexpr bool std::ranges::enable_view> = true;
// Iterators for optional have life times that are not tied to the optional.
template
-inline constexpr bool std::ranges::enable_borrowed_range> = std::is_reference_v;
+inline constexpr bool std::ranges::enable_borrowed_range> = std::is_reference_v;
// Since P3168R2: Give std::optional Range Support.
#if defined(__cpp_lib_format_ranges)
template
-inline constexpr auto std::format_kind> = range_format::disabled;
+inline constexpr auto std::format_kind> = range_format::disabled;
#endif
-namespace beman::optional26 {
+namespace beman::optional {
template
concept is_derived_from_optional = requires(const T& t) { // exposition only
[](const optional&) {}(t);
@@ -1432,17 +1432,16 @@ template
constexpr void optional::reset() noexcept {
value_ = nullptr;
}
-} // namespace beman::optional26
+} // namespace beman::optional
namespace std {
template
requires requires(T a) {
{ std::hash>{}(a) } -> std::convertible_to;
}
-struct hash> {
+struct hash> {
static_assert(!is_reference_v, "hash is not enabled for reference types");
- size_t operator()(const beman::optional26::optional& o) const
- noexcept(noexcept(hash>{}(*o))) {
+ size_t operator()(const beman::optional::optional& o) const noexcept(noexcept(hash>{}(*o))) {
if (o) {
return std::hash>{}(*o);
} else {
@@ -1452,4 +1451,4 @@ struct hash> {
};
} // namespace std
-#endif // BEMAN_OPTIONAL26_OPTIONAL_HPP
+#endif // BEMAN_OPTIONAL_OPTIONAL_HPP
diff --git a/include/beman/optional26/CMakeLists.txt b/include/beman/optional26/CMakeLists.txt
deleted file mode 100644
index e43fc93..0000000
--- a/include/beman/optional26/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# include/beman/optional26/CMakeLists.txt -*-cmake-*-
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-target_sources(
- beman_optional26
- PUBLIC
- FILE_SET beman_optional26_headers
- TYPE HEADERS
- FILES
- optional.hpp
- detail/iterator.hpp
- detail/stl_interfaces/config.hpp
- detail/stl_interfaces/fwd.hpp
- detail/stl_interfaces/iterator_interface.hpp
-)
-
-install(
- TARGETS beman_optional26
- FILE_SET beman_optional26_headers
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- COMPONENT beman_optional26_development
-)
-
-install(
- TARGETS beman_optional26
- EXPORT beman_optional26_export
- DESTINATION
- ${CMAKE_INSTALL_LIBDIR}
- FILE_SET beman_optional26_headers
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
- COMPONENT beman_optional26_development
-)
-
-install(
- EXPORT beman_optional26_export
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/beman/optional26/
- NAMESPACE Beman::Optional26::
- FILE beman_optional26.cmake
- EXPORT_LINK_INTERFACE_LIBRARIES
- COMPONENT beman_optional26_development
-)
diff --git a/include/beman/optional26/detail/stl_interfaces/config.hpp b/include/beman/optional26/detail/stl_interfaces/config.hpp
deleted file mode 100644
index 68ad40c..0000000
--- a/include/beman/optional26/detail/stl_interfaces/config.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// include/beman/optional26/detail/stl_interfaces/config.hpp -*-C++-*-
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-// Copyright (C) 2020 T. Zachary Laine
-//
-// Distributed under the Boost Software License, Version 1.0. (See
-// accompanying file LICENSE_1_0.txt or copy at
-// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONFIG_HPP
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_CONFIG_HPP
-
-// Included for definition of __cpp_lib_concepts.
-#include
-
-#if defined(__cpp_lib_concepts) && defined(__cpp_lib_ranges) && \
- !defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DISABLE_CONCEPTS)
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS 1
-#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS 0
-#endif
-
-#if defined(__cpp_explicit_this_parameter) && BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && \
- !defined(BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_DISABLE_DEDUCED_THIS)
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 1
-#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS 0
-#endif
-
-// The inline namespaces v1, v2, and v3 represent C++14, C++20, and C++23 and
-// later, respectively. v1 is inline for standards before C++20, and v2 is
-// inline for C++20 and later. Note that this only applies to code for which
-// multiple vI namespace alternatives exist. For example, some instances of
-// the v1 namespace may still be inline, if there is no v2 version of its
-// contents.
-#if !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 inline namespace v1
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
-#elif BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_CONCEPTS && !BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_USE_DEDUCED_THIS
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 inline namespace v2
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 namespace v3
-#else
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V1 namespace v1
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V2 namespace v2
-#define BEMAN_OPTIONAL26_DETAIL_STL_INTERFACES_NAMESPACE_V3 inline namespace v3
-#endif
-
-#endif
diff --git a/src/beman/optional26/tests/CMakeLists.txt b/src/beman/optional/tests/CMakeLists.txt
similarity index 75%
rename from src/beman/optional26/tests/CMakeLists.txt
rename to src/beman/optional/tests/CMakeLists.txt
index 5a2c1ad..b3bf63e 100644
--- a/src/beman/optional26/tests/CMakeLists.txt
+++ b/src/beman/optional/tests/CMakeLists.txt
@@ -1,15 +1,15 @@
# cmake-format: off
-# src/beman/optional26/tests/CMakeLists.txt -*-makefile-*-
+# src/beman/optional/tests/CMakeLists.txt -*-makefile-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on
include(GoogleTest)
# Tests
-# add_executable(beman_optional26_test)
+# add_executable(beman_optional_test)
target_sources(
- beman_optional26_test
+ beman_optional_test
PRIVATE
optional.t.cpp
optional_constexpr.t.cpp
@@ -20,16 +20,16 @@ target_sources(
)
target_sources(
- beman_optional26_test
+ beman_optional_test
PRIVATE
- FILE_SET beman_optional26_test_headers
+ FILE_SET beman_optional_test_headers
TYPE HEADERS
FILES test_types.hpp test_utilities.hpp
)
target_link_libraries(
- beman_optional26_test
- PRIVATE beman_optional26 GTest::gtest GTest::gtest_main
+ beman_optional_test
+ PRIVATE beman_optional GTest::gtest GTest::gtest_main
)
# Issue #32: Re-enable ASAN run CI/clang-19.
@@ -37,11 +37,11 @@ target_link_libraries(
# Note: clang-19 + gtest_discover_tests + Asan setup causes errors on some
# platforms. Temporary switch to gtest_add_tests and skip some Asan checks.
# Change also applied for CI flows.
-gtest_add_tests(TARGET beman_optional26_test "" AUTO)
+gtest_add_tests(TARGET beman_optional_test "" AUTO)
add_library(constructor_fails test_constructor_fail.cpp)
-target_link_libraries(constructor_fails PRIVATE beman_optional26)
+target_link_libraries(constructor_fails PRIVATE beman_optional)
set_target_properties(
constructor_fails
diff --git a/src/beman/optional26/tests/detail/iterator.t.cpp b/src/beman/optional/tests/detail/iterator.t.cpp
similarity index 69%
rename from src/beman/optional26/tests/detail/iterator.t.cpp
rename to src/beman/optional/tests/detail/iterator.t.cpp
index f511b13..190bdf0 100644
--- a/src/beman/optional26/tests/detail/iterator.t.cpp
+++ b/src/beman/optional/tests/detail/iterator.t.cpp
@@ -1,10 +1,10 @@
-// src/beman/optional26/tests/detail/iterator.t.cpp -*-C++-*-
+// src/beman/optional/tests/detail/iterator.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
/**
- * This file contains tests for beman::optional26::detail::contiguous_iterator.
+ * This file contains tests for beman::optional::detail::contiguous_iterator.
*/
-#include
+#include
#include
#include
@@ -23,14 +23,14 @@
} else \
EXPECT_EQ(val1, val2)
-namespace beman::optional26::tests {
+namespace beman::optional::tests {
// Dummy containers helper.
struct container {};
-} // namespace beman::optional26::tests
+} // namespace beman::optional::tests
-using namespace beman::optional26::tests;
+using namespace beman::optional::tests;
TEST(IteratorTest, IteratorConcepts) {
const auto test = [](auto&& it) {
@@ -47,24 +47,24 @@ TEST(IteratorTest, IteratorConcepts) {
};
// non-const iterators
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
// const iterators
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
- test(beman::optional26::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
+ test(beman::optional::detail::contiguous_iterator{});
}
TEST(IteratorTest, DereferenceOperator) {
auto lambda = [&] {
std::vector v{10, 20, 30, 40, 50};
- auto it = beman::optional26::detail::contiguous_iterator{v.data()};
+ auto it = beman::optional::detail::contiguous_iterator{v.data()};
CONSTEXPR_EXPECT_EQ(*it, 10);
*it = 100;
@@ -101,8 +101,8 @@ TEST(IteratorTest, ForwardIterator) {
CONSTEXPR_EXPECT_EQ(*it, 50);
};
- test(beman::optional26::detail::contiguous_iterator{v.data()});
- test(beman::optional26::detail::contiguous_iterator{cv.data()});
+ test(beman::optional::detail::contiguous_iterator{v.data()});
+ test(beman::optional::detail::contiguous_iterator{cv.data()});
};
static_assert((lambda(), true));
lambda();
@@ -124,8 +124,8 @@ TEST(IteratorTest, BidirectionalIterator) {
CONSTEXPR_EXPECT_EQ(*it, 10);
};
- test(beman::optional26::detail::contiguous_iterator{v.data()});
- test(beman::optional26::detail::contiguous_iterator{cv.data()});
+ test(beman::optional::detail::contiguous_iterator{v.data()});
+ test(beman::optional::detail::contiguous_iterator{cv.data()});
};
static_assert((lambda(), true));
lambda();
@@ -155,8 +155,8 @@ TEST(IteratorTest, RandomAccessIterator) {
CONSTEXPR_EXPECT_EQ(*it, 30);
};
- test(beman::optional26::detail::contiguous_iterator{v.data()});
- test(beman::optional26::detail::contiguous_iterator{cv.data()});
+ test(beman::optional::detail::contiguous_iterator{v.data()});
+ test(beman::optional::detail::contiguous_iterator{cv.data()});
};
static_assert((lambda(), true));
lambda();
@@ -169,8 +169,8 @@ TEST(IteratorTest, ContainerType) {
using containter_type1 = typename std::remove_reference_t;
using containter_type2 = typename std::remove_reference_t;
- auto it1 = beman::optional26::detail::contiguous_iterator{};
- auto it2 = beman::optional26::detail::contiguous_iterator{};
+ auto it1 = beman::optional::detail::contiguous_iterator{};
+ auto it2 = beman::optional::detail::contiguous_iterator{};
static_assert(std::is_same_v);
};
@@ -187,8 +187,8 @@ TEST(IteratorTest, ContainerType) {
using pointer_type1 = typename containter_type1::pointer;
using pointer_type2 = typename containter_type2::pointer;
- auto it1 = beman::optional26::detail::contiguous_iterator{};
- auto it2 = beman::optional26::detail::contiguous_iterator{};
+ auto it1 = beman::optional::detail::contiguous_iterator{};
+ auto it2 = beman::optional::detail::contiguous_iterator{};
static_assert(!std::is_same_v);
};
diff --git a/src/beman/optional26/tests/optional.t.cpp b/src/beman/optional/tests/optional.t.cpp
similarity index 50%
rename from src/beman/optional26/tests/optional.t.cpp
rename to src/beman/optional/tests/optional.t.cpp
index 1fdce09..e425345 100644
--- a/src/beman/optional26/tests/optional.t.cpp
+++ b/src/beman/optional/tests/optional.t.cpp
@@ -1,11 +1,11 @@
-// src/beman/optional26/tests/optional.t.cpp -*-C++-*-
+// src/beman/optional/tests/optional.t.cpp -*-C++-*-
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include
+#include
-#include // test 2nd include OK
+#include // test 2nd include OK
-#include
+#include
#include
#include
@@ -16,130 +16,130 @@
#include
TEST(OptionalTest, Constructors) {
- beman::optional26::optional i1;
- beman::optional26::optional i2{beman::optional26::nullopt};
+ beman::optional::optional i1;
+ beman::optional::optional i2{beman::optional::nullopt};
std::ignore = i1;
std::ignore = i2;
- int i = 0;
- beman::optional26::optional i3 = i;
- std::ignore = i3;
+ int i = 0;
+ beman::optional::optional i3 = i;
+ std::ignore = i3;
- using beman::optional26::tests::empty;
+ using beman::optional::tests::empty;
- beman::optional26::optional e1;
- beman::optional26::optional e2{beman::optional26::nullopt};
+ beman::optional::optional e1;
+ beman::optional::optional e2{beman::optional::nullopt};
- empty e{};
- beman::optional26::optional e3 = e;
- std::ignore = e1;
- std::ignore = e2;
- std::ignore = e3;
+ empty e{};
+ beman::optional::optional e3 = e;
+ std::ignore = e1;
+ std::ignore = e2;
+ std::ignore = e3;
}
TEST(OptionalTest, Constructors2) {
- beman::optional26::optional o1;
+ beman::optional::optional o1;
EXPECT_TRUE(!o1);
- beman::optional26::optional o2 = beman::optional26::nullopt;
+ beman::optional::optional o2 = beman::optional::nullopt;
EXPECT_TRUE(!o2);
- beman::optional26::optional o3 = 42;
+ beman::optional::optional o3 = 42;
EXPECT_TRUE(*o3 == 42);
- beman::optional26::optional o4 = o3;
+ beman::optional::optional o4 = o3;
EXPECT_TRUE(*o4 == 42);
- beman::optional26::optional o5 = o1;
+ beman::optional::optional o5 = o1;
EXPECT_TRUE(!o5);
- beman::optional26::optional o6 = std::move(o3);
+ beman::optional::optional o6 = std::move(o3);
EXPECT_TRUE(*o6 == 42);
- beman::optional26::optional o7 = 42;
+ beman::optional::optional o7 = 42;
EXPECT_TRUE(*o7 == 42);
- beman::optional26::optional o8 = o7;
+ beman::optional::optional o8 = o7;
EXPECT_TRUE(*o8 == 42);
- beman::optional26::optional o9 = std::move(o7);
+ beman::optional::optional o9 = std::move(o7);
EXPECT_TRUE(*o9 == 42);
{
- beman::optional26::optional o;
+ beman::optional::optional o;
EXPECT_TRUE(!o);
- beman::optional26::optional oo = o;
+ beman::optional::optional oo = o;
EXPECT_TRUE(!oo);
}
{
- auto i = 42;
- beman::optional26::optional o = i;
+ auto i = 42;
+ beman::optional::optional o = i;
EXPECT_TRUE(o);
EXPECT_TRUE(*o == 42);
- beman::optional26::optional oo = o;
+ beman::optional::optional oo = o;
EXPECT_TRUE(oo);
EXPECT_TRUE(*oo == 42);
}
- using beman::optional26::tests::base;
+ using beman::optional::tests::base;
std::vector v;
v.emplace_back();
- beman::optional26::optional> ov = std::move(v);
+ beman::optional::optional> ov = std::move(v);
EXPECT_TRUE(ov->size() == 1);
}
TEST(OptionalTest, Constructors3) {
- beman::optional26::optional ie;
- beman::optional26::optional