Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename beman.example to beman.exemplar #19

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ci/docker/rockylinux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

4 changes: 2 additions & 2 deletions .ci/docker/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -24,6 +24,6 @@ if(BUILD_TESTING)
FetchContent_MakeAvailable(googletest)
endif()

add_subdirectory(src/beman/example)
add_subdirectory(src/beman/exemplar)

add_subdirectory(examples)
10 changes: 5 additions & 5 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 4 additions & 4 deletions examples/identity_as_default_projection.cpp
Original file line number Diff line number Diff line change
@@ -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.hpp> // beman::example::identity
#include <beman/exemplar/identity.hpp> // beman::exemplar::identity

#include <algorithm>
#include <functional> // std::identity
Expand Down Expand Up @@ -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 <std::ranges::input_range R,
typename Projection = beman::example::identity> // <- 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);
Expand Down
4 changes: 2 additions & 2 deletions examples/identity_direct_usage.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/example/identity.hpp>
#include <beman/exemplar/identity.hpp>

#include <iostream>

int main() {
std::cout << beman::example::identity()(2024) << '\n';
std::cout << beman::exemplar::identity()(2024) << '\n';
return 0;
}
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -22,7 +22,7 @@

#include <utility> // std::forward

namespace beman::example {
namespace beman::exemplar {

struct __is_transparent; // not defined

Expand All @@ -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
32 changes: 0 additions & 32 deletions src/beman/example/CMakeLists.txt

This file was deleted.

32 changes: 32 additions & 0 deletions src/beman/exemplar/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../include>)

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()
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/example/identity.hpp>
#include <beman/exemplar/identity.hpp>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <beman/example/identity.hpp>
#include <beman/exemplar/identity.hpp>

#include <gtest/gtest.h>

Expand All @@ -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));
}
}

Expand All @@ -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);
}
}
Expand All @@ -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));
Expand All @@ -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);
Expand Down
Loading