diff --git a/.ci/docker/rockylinux.Dockerfile b/.ci/docker/rockylinux.Dockerfile index 5ed30db..297e7f0 100644 --- a/.ci/docker/rockylinux.Dockerfile +++ b/.ci/docker/rockylinux.Dockerfile @@ -30,6 +30,6 @@ ARG cmake_args= ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on RUN cmake -B build -S . "$cmake_args" RUN cmake --build build --verbose -RUN cmake --install build --prefix /opt/Beman.Example -RUN find /opt/Beman.Example -type f +RUN cmake --install build --prefix /opt/beman.example +RUN find /opt/beman.example -type f diff --git a/.ci/docker/ubuntu.Dockerfile b/.ci/docker/ubuntu.Dockerfile index 7a8331e..cfb3c81 100644 --- a/.ci/docker/ubuntu.Dockerfile +++ b/.ci/docker/ubuntu.Dockerfile @@ -27,7 +27,8 @@ RUN sysctl vm.mmap_rnd_bits=28 # Build. ENV CC="$cc" CXX="$cxx" CMAKE_GENERATOR="Ninja" CMAKE_EXPORT_COMPILE_COMMANDS=on +RUN ls -lR src RUN cmake -B build -S . "$cmake_args" RUN cmake --build build --verbose -RUN cmake --install build --prefix /opt/Beman.Example -RUN find /opt/Beman.Example -type f +RUN cmake --install build --prefix /opt/beman.example +RUN find /opt/beman.example -type f diff --git a/CMakeLists.txt b/CMakeLists.txt index bfbaddb..f4df2e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.23) project( - Beman.Example # CMake Project Name, which is also the name of the top-level + beman.example # CMake Project Name, which is also the name of the top-level # targets (e.g., library, executable, etc.). DESCRIPTION "A Beman Library Example" LANGUAGES CXX) @@ -24,6 +24,6 @@ if(BUILD_TESTING) FetchContent_MakeAvailable(googletest) endif() -add_subdirectory(src/Beman/Example) +add_subdirectory(src/beman/example) add_subdirectory(examples) diff --git a/README.md b/README.md index 7ebc303..7de6c2e 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception --> -# Beman.Example: A Beman Library Example +# beman.example: A Beman Library Example ![Continuous Integration Tests](https://github.com/beman-project/Example/actions/workflows/ci_tests.yml/badge.svg) -`Beman.Example` is a minimal C++ library conforming to [The Beman Standard](https://github.com/beman-project/beman/blob/main/docs/beman-standard.md). This can be used as a template for those intending to write Beman libraries. It may also find use as a minimal and modern C++ project structure. +`beman.example` is a minimal C++ library conforming to [The Beman Standard](https://github.com/beman-project/beman/blob/main/docs/beman-standard.md). This can be used as a template for those intending to write Beman libraries. It may also find use as a minimal and modern C++ project structure. Implements: `std::identity` proposed in [Standard Library Concepts (P0898R3)](https://wg21.link/P0898R3). @@ -15,13 +15,13 @@ Implements: `std::identity` proposed in [Standard Library Concepts (P0898R3)](ht `std::identity` is a function object type whose `operator()` returns its argument unchanged. `std::identity` serves as the default projection in constrained algorithms. Its direct usage is usually not needed. -### Example: default projection in constrained algorithms +### Usage: default projection in constrained algorithms - The following code snippet illustrates how we can achieve a default projection using `Beman::Example::identity`: + The following code snippet illustrates how we can achieve a default projection using `beman::example::identity`: ```cpp -#include +#include // Class with a pair of values. struct Pair @@ -43,7 +43,7 @@ struct Pair // e.g., pairs with custom projection: {1:one, 2:two, 3:three} template -void print(const std::string_view rem, R &&range, Projection projection = Beman::Example::identity>) +void print(const std::string_view rem, R &&range, Projection projection = beman::example::identity>) { std::cout << rem << '{'; std::ranges::for_each( @@ -64,17 +64,16 @@ int main() }; // Print the pairs using the default projection. - std::cout << "Default projection:\n"; - print("\tpairs with Beman: ", pairs); + print("\tpairs with beman: ", pairs); return 0; } ``` -Full runable examples can be found in `examples/` (e.g., [./examples/Beman/Beman.Example/examples/identity_as_default_projection.cpp.cpp](./examples/Beman/Beman.Example/examples/identity_as_default_projection.cpp.cpp)). +Full runable examples can be found in `examples/` (e.g., [./examples/identity_as_default_projection.cpp.cpp](./examples/identity_as_default_projection.cpp.cpp)). -## Building Beman.Example +## Building beman.example ### Dependencies @@ -100,7 +99,7 @@ Build-time dependencies: # Install tools: apt-get install -y cmake make ninja-build -# Example of toolchains: +# Toolchains: apt-get install \ g++-14 gcc-14 gcc-13 g++-14 \ clang-18 clang++-18 clang-17 clang++-17 @@ -128,15 +127,15 @@ apt-get install \ -### How to build Beman.Example +### How to build beman.example -This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `libBeman.Example.a` library, ready to package with its headers: +This project strives to be as normal and simple a CMake project as possible. This build workflow in particular will work, producing a static `libbeman.example.a` library, ready to package with its headers: ```shell cmake -B build -S . -DCMAKE_CXX_STANDARD=20 cmake --build build ctest --test-dir build -cmake --install build --prefix /opt/Beman.Example +cmake --install build --prefix /opt/beman.example ```
@@ -157,26 +156,26 @@ $ cmake -B build -S . -DCMAKE_CXX_STANDARD=20 # Build example. $ cmake --build build -[ 10%] Building CXX object src/Beman/Example/CMakeFiles/Beman.Example.dir/identity.cpp.o -[ 20%] Linking CXX static library libBeman.Example.a -[ 20%] Built target Beman.Example +[ 10%] Building CXX object src/beman/example/CMakeFiles/beman.example.dir/identity.cpp.o +[ 20%] Linking CXX static library libbeman.example.a +[ 20%] Built target beman.example [ 30%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o [ 40%] Linking CXX static library ../../../lib/libgtest.a [ 40%] Built target gtest [ 50%] Building CXX object _deps/googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o [ 60%] Linking CXX static library ../../../lib/libgtest_main.a [ 60%] Built target gtest_main -[ 70%] Building CXX object src/Beman/Example/tests/CMakeFiles/Beman.Example.Test.dir/identity.t.cpp.o -[ 80%] Linking CXX executable Beman.Example.Test -[ 80%] Built target Beman.Example.Test +[ 70%] Building CXX object src/beman/example/tests/CMakeFiles/beman.example.Test.dir/identity.t.cpp.o +[ 80%] Linking CXX executable beman.example.Test +[ 80%] Built target beman.example.Test [ 90%] Building CXX object examples/CMakeFiles/identity_usage.dir/identity_usage.cpp.o [100%] Linking CXX executable identity_usage [100%] Built target identity_usage # Run tests example. $ ctest --test-dir build -Internal ctest changing into directory: /home/dariusn/git/Beman/Beman.Example/build -Test project /home/dariusn/git/Beman/Beman.Example/build +Internal ctest changing into directory: /path/to/your/repo/build +Test project /path/to/your/repo/build Start 1: IdentityTest.call_identity_with_int 1/4 Test #1: IdentityTest.call_identity_with_int ........... Passed 0.00 sec Start 2: IdentityTest.call_identity_with_custom_type @@ -203,24 +202,24 @@ $ build/examples/identity_usage Install example (verbose logs) ```shell -# Install build artifacts from `build` directory into `opt/Beman.Example` path. -$ cmake --install build --prefix /opt/Beman.Example +# Install build artifacts from `build` directory into `opt/beman.example` path. +$ cmake --install build --prefix /opt/beman.example -- Install configuration: "" --- Up-to-date: /opt/Beman.Example/lib/libBeman.Example.a --- Up-to-date: /opt/Beman.Example/include --- Up-to-date: /opt/Beman.Example/include/Beman --- Up-to-date: /opt/Beman.Example/include/Beman/Example --- Up-to-date: /opt/Beman.Example/include/Beman/Example/identity.hpp +-- Up-to-date: /opt/beman.example/lib/libbeman.example.a +-- Up-to-date: /opt/beman.example/include +-- Up-to-date: /opt/beman.example/include/beman +-- Up-to-date: /opt/beman.example/include/beman/example +-- Up-to-date: /opt/beman.example/include/beman/example/identity.hpp # Check tree. -$ tree /opt/Beman.Example -/opt/Beman.Example +$ tree /opt/beman.example +/opt/beman.example ├── include -│   └── Beman -│   └── Example +│   └── beman +│   └── example │   └── identity.hpp └── lib - └── libBeman.Example.a + └── libbeman.example.a 5 directories, 2 files ``` @@ -238,54 +237,54 @@ cmake -B build -S . -DBUILD_TESTING=OFF
-## Integrate Beman.Example into your project +## Integrate beman.example into your project
- Use Beman.Example directly from C++ + Use beman.example directly from C++ -If you want to use `Beman.Example` from your project, you can include `Beman/Example/*.hpp` files from your C++ source files +If you want to use `beman.example` from your project, you can include `beman/example/*.hpp` files from your C++ source files ```cpp -#include +#include ``` -and directly link with `libBeman.Example.a` +and directly link with `libbeman.example.a` ```shell -# Assume /opt/Beman.Example staging directory. +# Assume /opt/beman.example staging directory. $ c++ -o identity_usage examples/identity_usage.cpp \ - -I /opt/Beman.Example/include/ \ - -lBeman.Example -L /opt/Beman.Example/lib/ + -I /opt/beman.example/include/ \ + -L/opt/beman.example/lib/ -lbeman.example ```
- Use Beman.Example directly from CMake + Use beman.example directly from CMake -For CMake based projects, you will need to use the `Beman.Example` CMake module to define the `Beman.Example` CMake target: +For CMake based projects, you will need to use the `beman.example` CMake module to define the `beman::example` CMake target: ```cmake -find_package(Beman.Example REQUIRED) +find_package(beman.example REQUIRED) ``` -You will also need to add `Beman::Example` to the link libraries of any libraries or executables that include `Beman/Example/*.hpp` in their source or header file. +You will also need to add `beman::example` to the link libraries of any libraries or executables that include `beman/example/*.hpp` in their source or header file. ```cmake -target_link_libraries(yourlib PUBLIC Beman::Example) +target_link_libraries(yourlib PUBLIC beman::example) ```
- Use Beman.Example from other build systems + Use beman.example from other build systems -Build systems that support `pkg-config` by providing a `Beman.Example.pc` file. Build systems that support interoperation via `pkg-config` should be able to detect `Beman.Example` for you automatically. +Build systems that support `pkg-config` by providing a `beman.example.pc` file. Build systems that support interoperation via `pkg-config` should be able to detect `beman.example` for you automatically.
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 079101c..190e6d5 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,11 +1,11 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(ALL_EXAMPLES identity_as_default_projection identity_direct_usage) +set(ALL_EXAMPLES + #identity_as_default_projection +identity_direct_usage) foreach(example ${ALL_EXAMPLES}) - add_executable(${example} "") - + add_executable(${example}) target_sources(${example} PRIVATE ${example}.cpp) - - target_link_libraries(${example} Beman::Example) + target_link_libraries(${example} beman::example) endforeach() diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp index 88f34f2..aa1fef8 100644 --- a/examples/identity_as_default_projection.cpp +++ b/examples/identity_as_default_projection.cpp @@ -1,11 +1,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// This example demonstrates the usage of Beman::Example::identity as a default projection in a range-printer. +// This example demonstrates the usage of beman::example::identity as a default projection in a range-printer. // Requires: range support (C++20) and std::identity support (C++20). // TODO Darius: Do we need to selectively compile this example? // Or should we assume that this project is compiled with C++20 support only? -#include // Beman::Example::identity +#include // beman::example::identity #include #include // std::identity @@ -44,9 +44,9 @@ void print_helper(const std::string_view rem, R &&range, Projection projection) std::cout << "}\n"; }; -// Print wrapper with Beman::Example::identity. +// Print wrapper with beman::example::identity. template // <- Notice the default projection. + typename Projection = beman::example::identity> // <- Notice the default projection. void print_beman(const std::string_view rem, R &&range, Projection projection = {}) { print_helper(rem, range, projection); @@ -71,12 +71,12 @@ int main() // Print the pairs using the default projection. std::cout << "Default projection:\n"; - print_beman("\tpairs with Beman: ", pairs); + print_beman("\tpairs with beman: ", pairs); print_std("\tpairs with std: ", pairs); // Print the pairs using a custom projection. std::cout << "Custom projection:\n"; - print_beman("\tpairs with Beman: ", pairs, + print_beman("\tpairs with beman: ", pairs, [](const auto &p) { return std::to_string(p.n) + ':' + p.s; }); print_std("\tpairs with std: ", pairs, diff --git a/examples/identity_direct_usage.cpp b/examples/identity_direct_usage.cpp index 184f59d..90e8444 100644 --- a/examples/identity_direct_usage.cpp +++ b/examples/identity_direct_usage.cpp @@ -1,10 +1,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include int main() { - std::cout << Beman::Example::identity()(2024) << '\n'; + std::cout << beman::example::identity()(2024) << '\n'; return 0; } diff --git a/include/Beman/Example/identity.hpp b/include/beman/example/identity.hpp similarity index 90% rename from include/Beman/Example/identity.hpp rename to include/beman/example/identity.hpp index ab32869..955fa2d 100644 --- a/include/Beman/Example/identity.hpp +++ b/include/beman/example/identity.hpp @@ -4,7 +4,7 @@ #define BEMAN_EXAMPLE_IDENTITY_HPP // C++ Standard Library: std::identity equivalent. -// Check https://eel.is/c++draft/func.identity: +// See https://eel.is/c++draft/func.identity: // // 22.10.12 Class identity [func.identity] // @@ -22,7 +22,7 @@ #include // std::forward -namespace Beman::Example { +namespace beman::example { struct __is_transparent; // not defined @@ -43,6 +43,6 @@ struct identity using is_transparent = __is_transparent; }; -} // namespace Beman::Example +} // namespace beman::example #endif // BEMAN_EXAMPLE_IDENTITY_HPP diff --git a/src/Beman/Example/CMakeLists.txt b/src/beman/example/CMakeLists.txt similarity index 94% rename from src/Beman/Example/CMakeLists.txt rename to src/beman/example/CMakeLists.txt index bf56b96..199c8ce 100644 --- a/src/Beman/Example/CMakeLists.txt +++ b/src/beman/example/CMakeLists.txt @@ -1,7 +1,7 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception set(TARGET_LIBRARY ${CMAKE_PROJECT_NAME}) -set(TARGET_LIBRARY_ALIAS "Beman::Example") +set(TARGET_LIBRARY_ALIAS "beman::example") set(TARGET_LIBRARY_BINARY "lib${TARGET_LIBRARY}") add_library(${TARGET_LIBRARY} STATIC) diff --git a/src/Beman/Example/identity.cpp b/src/beman/example/identity.cpp similarity index 61% rename from src/Beman/Example/identity.cpp rename to src/beman/example/identity.cpp index 600f41a..00e3758 100644 --- a/src/Beman/Example/identity.cpp +++ b/src/beman/example/identity.cpp @@ -1,3 +1,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include diff --git a/src/Beman/Example/tests/CMakeLists.txt b/src/beman/example/tests/CMakeLists.txt similarity index 84% rename from src/Beman/Example/tests/CMakeLists.txt rename to src/beman/example/tests/CMakeLists.txt index 8b44994..d807d27 100644 --- a/src/Beman/Example/tests/CMakeLists.txt +++ b/src/beman/example/tests/CMakeLists.txt @@ -9,6 +9,6 @@ add_executable(${TARGET_LIBRARY_TESTS}) target_sources(${TARGET_LIBRARY_TESTS} PRIVATE identity.t.cpp) target_link_libraries(${TARGET_LIBRARY_TESTS} - PRIVATE Beman::Example GTest::gtest GTest::gtest_main) + PRIVATE beman::example GTest::gtest GTest::gtest_main) gtest_add_tests(${TARGET_LIBRARY_TESTS} "" AUTO) diff --git a/src/Beman/Example/tests/identity.t.cpp b/src/beman/example/tests/identity.t.cpp similarity index 83% rename from src/Beman/Example/tests/identity.t.cpp rename to src/beman/example/tests/identity.t.cpp index 3f5384f..0c39d9c 100644 --- a/src/Beman/Example/tests/identity.t.cpp +++ b/src/beman/example/tests/identity.t.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include #include @@ -11,7 +11,7 @@ TEST(IdentityTest, call_identity_with_int) { for (int i = -100; i < 100; ++i) { - EXPECT_EQ(i, Beman::Example::identity()(i)); + EXPECT_EQ(i, beman::example::identity()(i)); } } @@ -25,7 +25,7 @@ TEST(IdentityTest, call_identity_with_custom_type) for (int i = -100; i < 100; ++i) { const S s{i}; - const S s_id = Beman::Example::identity()(s); + const S s_id = beman::example::identity()(s); EXPECT_EQ(s.i, s_id.i); } } @@ -35,7 +35,7 @@ TEST(IdentityTest, compare_std_vs_beman) // Requires: std::identity support. #if defined(__cpp_lib_identity) std::identity std_id; - Beman::Example::identity beman_id; + beman::example::identity beman_id; for (int i = -100; i < 100; ++i) { EXPECT_EQ(std_id(i), beman_id(i)); @@ -48,7 +48,7 @@ TEST(IdentityTest, check_is_transparent) // Requires: transparent operators support. #if defined(__cpp_lib_transparent_operators) - Beman::Example::identity id; + beman::example::identity id; const auto container = {1, 2, 3, 4, 5}; auto it = std::find(std::begin(container), std::end(container), 3);