From 4944d03b001450e5a02540c8305f1831a3d46e44 Mon Sep 17 00:00:00 2001 From: David Sankel Date: Thu, 19 Sep 2024 21:54:22 -0600 Subject: [PATCH] Rename beman.example to beman.exemplar Calling this project exemplar is more accurate and mitigates some of the confusion created by having an "examples" folder within an "example" project. Once this chnage merges, I intend to rename the repository to exemplar. --- .ci/docker/rockylinux.Dockerfile | 4 +-- .ci/docker/ubuntu.Dockerfile | 4 +-- CMakeLists.txt | 8 ++--- examples/CMakeLists.txt | 10 +++--- examples/identity_as_default_projection.cpp | 8 ++--- examples/identity_direct_usage.cpp | 4 +-- .../beman/{example => exemplar}/identity.hpp | 10 +++--- src/beman/example/CMakeLists.txt | 32 ------------------- src/beman/exemplar/CMakeLists.txt | 32 +++++++++++++++++++ src/beman/{example => exemplar}/identity.cpp | 2 +- .../{example => exemplar}/identity.t.cpp | 10 +++--- 11 files changed, 62 insertions(+), 62 deletions(-) rename include/beman/{example => exemplar}/identity.hpp (84%) delete mode 100644 src/beman/example/CMakeLists.txt create mode 100644 src/beman/exemplar/CMakeLists.txt rename src/beman/{example => exemplar}/identity.cpp (60%) rename src/beman/{example => exemplar}/identity.t.cpp (83%) diff --git a/.ci/docker/rockylinux.Dockerfile b/.ci/docker/rockylinux.Dockerfile index 297e7f0..493daf3 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.exemplar +RUN find /opt/beman.exemplar -type f diff --git a/.ci/docker/ubuntu.Dockerfile b/.ci/docker/ubuntu.Dockerfile index cfb3c81..8741084 100644 --- a/.ci/docker/ubuntu.Dockerfile +++ b/.ci/docker/ubuntu.Dockerfile @@ -30,5 +30,5 @@ 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.exemplar +RUN find /opt/beman.exemplar -type f diff --git a/CMakeLists.txt b/CMakeLists.txt index f4df2e9..6c1642a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,9 @@ cmake_minimum_required(VERSION 3.23) project( - 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" + beman.exemplar # CMake Project Name, which is also the name of the top-level + # targets (e.g., library, executable, etc.). + DESCRIPTION "A Beman library exemplar" LANGUAGES CXX) include(CTest) @@ -24,6 +24,6 @@ if(BUILD_TESTING) FetchContent_MakeAvailable(googletest) endif() -add_subdirectory(src/beman/example) +add_subdirectory(src/beman/exemplar) add_subdirectory(examples) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a4bbcf3..60032ff 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 +set(ALL_EXAMPLES + #identity_as_default_projection identity_direct_usage) foreach(example ${ALL_EXAMPLES}) - add_executable(beman.example.examples.${example}) - target_sources(beman.example.examples.${example} PRIVATE ${example}.cpp) - target_link_libraries(beman.example.examples.${example} beman::example) + add_executable(beman.exemplar.examples.${example}) + target_sources(beman.exemplar.examples.${example} PRIVATE ${example}.cpp) + target_link_libraries(beman.exemplar.examples.${example} beman::exemplar) endforeach() diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp index aa1fef8..1fd8da6 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::exemplar::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::exemplar::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::exemplar::identity. template // <- Notice the default projection. + typename Projection = beman::exemplar::identity> // <- Notice the default projection. void print_beman(const std::string_view rem, R &&range, Projection projection = {}) { print_helper(rem, range, projection); diff --git a/examples/identity_direct_usage.cpp b/examples/identity_direct_usage.cpp index 90e8444..b18f8dd 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::exemplar::identity()(2024) << '\n'; return 0; } diff --git a/include/beman/example/identity.hpp b/include/beman/exemplar/identity.hpp similarity index 84% rename from include/beman/example/identity.hpp rename to include/beman/exemplar/identity.hpp index 955fa2d..0a121eb 100644 --- a/include/beman/example/identity.hpp +++ b/include/beman/exemplar/identity.hpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef BEMAN_EXAMPLE_IDENTITY_HPP -#define BEMAN_EXAMPLE_IDENTITY_HPP +#ifndef BEMAN_EXEMPLAR_IDENTITY_HPP +#define BEMAN_EXEMPLAR_IDENTITY_HPP // C++ Standard Library: std::identity equivalent. // See https://eel.is/c++draft/func.identity: @@ -22,7 +22,7 @@ #include // std::forward -namespace beman::example { +namespace beman::exemplar { struct __is_transparent; // not defined @@ -43,6 +43,6 @@ struct identity using is_transparent = __is_transparent; }; -} // namespace beman::example +} // namespace beman::exemplar -#endif // BEMAN_EXAMPLE_IDENTITY_HPP +#endif // BEMAN_EXEMPLAR_IDENTITY_HPP diff --git a/src/beman/example/CMakeLists.txt b/src/beman/example/CMakeLists.txt deleted file mode 100644 index 41e7961..0000000 --- a/src/beman/example/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -add_library(beman.example STATIC) -add_library(beman::example ALIAS beman.example) - -target_sources(beman.example PRIVATE identity.cpp) - -target_include_directories( - beman.example - PUBLIC $) - -install( - TARGETS beman.example - EXPORT beman.example - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -install( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/ - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - FILES_MATCHING - PATTERN "*.hpp") - -if(BUILD_TESTING) - include(GoogleTest) - - add_executable(beman.example.tests) - target_sources(beman.example.tests PRIVATE identity.t.cpp) - target_link_libraries(beman.example.tests - PRIVATE beman::example GTest::gtest GTest::gtest_main) - - gtest_add_tests(beman.example.tests "" AUTO) -endif() diff --git a/src/beman/exemplar/CMakeLists.txt b/src/beman/exemplar/CMakeLists.txt new file mode 100644 index 0000000..cb73ee3 --- /dev/null +++ b/src/beman/exemplar/CMakeLists.txt @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_library(beman.exemplar STATIC) +add_library(beman::exemplar ALIAS beman.exemplar) + +target_sources(beman.exemplar PRIVATE identity.cpp) + +target_include_directories( + beman.exemplar + PUBLIC $) + +install( + TARGETS beman.exemplar + EXPORT beman.exemplar + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +install( + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING + PATTERN "*.hpp") + +if(BUILD_TESTING) + include(GoogleTest) + + add_executable(beman.exemplar.tests) + target_sources(beman.exemplar.tests PRIVATE identity.t.cpp) + target_link_libraries(beman.exemplar.tests + PRIVATE beman::exemplar GTest::gtest GTest::gtest_main) + + gtest_add_tests(beman.exemplar.tests "" AUTO) +endif() diff --git a/src/beman/example/identity.cpp b/src/beman/exemplar/identity.cpp similarity index 60% rename from src/beman/example/identity.cpp rename to src/beman/exemplar/identity.cpp index 00e3758..21ef59d 100644 --- a/src/beman/example/identity.cpp +++ b/src/beman/exemplar/identity.cpp @@ -1,3 +1,3 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include diff --git a/src/beman/example/identity.t.cpp b/src/beman/exemplar/identity.t.cpp similarity index 83% rename from src/beman/example/identity.t.cpp rename to src/beman/exemplar/identity.t.cpp index 0c39d9c..520d323 100644 --- a/src/beman/example/identity.t.cpp +++ b/src/beman/exemplar/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::exemplar::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::exemplar::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::exemplar::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::exemplar::identity id; const auto container = {1, 2, 3, 4, 5}; auto it = std::find(std::begin(container), std::end(container), 3);