From 2f66546124c42d09510e1669a1198d85d4248f71 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 14:41:04 +0300 Subject: [PATCH 01/11] Add examples directory --- examples/CMakeLists.txt | 0 examples/identity_as_default_projection.cpp | 0 examples/identity_direct_usage.cpp | 0 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/identity_as_default_projection.cpp create mode 100644 examples/identity_direct_usage.cpp diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp new file mode 100644 index 0000000..e69de29 diff --git a/examples/identity_direct_usage.cpp b/examples/identity_direct_usage.cpp new file mode 100644 index 0000000..e69de29 From fe10beebd5a978a7b207197dc9defba56dff01d6 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 15:48:10 +0300 Subject: [PATCH 02/11] Add an example in examples directory --- CMakeLists.txt | 4 ++++ examples/CMakeLists.txt | 3 +++ examples/identity_as_default_projection.cpp | 0 examples/identity_direct_usage.cpp | 0 examples/sample_usage.cpp | 16 ++++++++++++++++ 5 files changed, 23 insertions(+) delete mode 100644 examples/identity_as_default_projection.cpp delete mode 100644 examples/identity_direct_usage.cpp create mode 100644 examples/sample_usage.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b928a6..25fa047 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,3 +47,7 @@ add_subdirectory(src/beman/copyable_function) if(BEMAN_COPYABLE_FUNCTION_BUILD_TESTS) add_subdirectory(tests/beman/copyable_function) endif() + +if(BEMAN_COPYABLE_FUNCTION_BUILD_TESTS) + add_subdirectory(examples) +endif() \ No newline at end of file diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e69de29..ce7b3e8 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(sample_usage sample_usage.cpp) + +target_link_libraries(sample_usage PRIVATE beman::copyable_function) \ No newline at end of file diff --git a/examples/identity_as_default_projection.cpp b/examples/identity_as_default_projection.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/examples/identity_direct_usage.cpp b/examples/identity_direct_usage.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/examples/sample_usage.cpp b/examples/sample_usage.cpp new file mode 100644 index 0000000..d8db9b8 --- /dev/null +++ b/examples/sample_usage.cpp @@ -0,0 +1,16 @@ +#include + +namespace exe = beman::copyable_function; + +// a Callable object +struct Callable { + int operator()() { return 42; } + int operator()() const noexcept { return 43; } +}; + +int main() +{ + beman::copyable_function f(Callable{}); + int x = f(); + return 0; +} From f943cf27b9b5c3ef390149168ff6034e67ea22c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Sat, 25 Apr 2026 15:52:42 +0300 Subject: [PATCH 03/11] Apply suggestion from @neatudarius --- examples/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index ce7b3e8..366f25c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,3 +1,3 @@ add_executable(sample_usage sample_usage.cpp) -target_link_libraries(sample_usage PRIVATE beman::copyable_function) \ No newline at end of file +target_link_libraries(sample_usage PRIVATE beman::copyable_function) From 88897d5341ca3ad8d5ffd5eb7836781eb95bdecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Sat, 25 Apr 2026 15:52:48 +0300 Subject: [PATCH 04/11] Apply suggestion from @neatudarius --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25fa047..dd9f81f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,4 +50,4 @@ endif() if(BEMAN_COPYABLE_FUNCTION_BUILD_TESTS) add_subdirectory(examples) -endif() \ No newline at end of file +endif() From 091478877096044173931a5f3a6dde4f5810ae4a Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:02:52 +0300 Subject: [PATCH 05/11] Add beman-tidy to .pre-commit-config.yaml --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddba471..d7d28cc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,3 +36,9 @@ repos: rev: v2.3.0 hooks: - id: codespell + + - repo: https://github.com/bemanproject/beman-tidy + rev: v0.3.1 + hooks: + - id: beman-tidy + args: [".", "--verbose", "--require-all"] From c5834449c9d197736b45233b0f3046b94477c9e4 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:06:44 +0300 Subject: [PATCH 06/11] Add beman-tidy to .pre-commit-config.yaml defaul only --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7d28cc..063301b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -41,4 +41,4 @@ repos: rev: v0.3.1 hooks: - id: beman-tidy - args: [".", "--verbose", "--require-all"] + args: [".", "--verbose"] From 4a246845b0f5d4efb467de6c7525746538ddcaad Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:22:30 +0300 Subject: [PATCH 07/11] restore main precommit config --- .pre-commit-config.yaml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6b631b0..a6adcbb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -37,8 +37,3 @@ repos: hooks: - id: codespell - - repo: https://github.com/bemanproject/beman-tidy - rev: v0.3.1 - hooks: - - id: beman-tidy - args: [".", "--verbose"] From 6590f709b2825ba5fdeaf38769565d84c9b0ca98 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:23:03 +0300 Subject: [PATCH 08/11] restore main precommit config --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a6adcbb..ad16ea7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -36,4 +36,3 @@ repos: rev: v2.3.0 hooks: - id: codespell - From 404cd22b26854beef764d46295fadf379b665d30 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:24:20 +0300 Subject: [PATCH 09/11] fix linter --- examples/sample_usage.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/sample_usage.cpp b/examples/sample_usage.cpp index d8db9b8..0ad1ef2 100644 --- a/examples/sample_usage.cpp +++ b/examples/sample_usage.cpp @@ -8,8 +8,7 @@ struct Callable { int operator()() const noexcept { return 43; } }; -int main() -{ +int main() { beman::copyable_function f(Callable{}); int x = f(); return 0; From 8e5e3ef23166ac0b9668d49474d2548686492429 Mon Sep 17 00:00:00 2001 From: Dragos Coscodan Date: Sat, 25 Apr 2026 16:44:32 +0300 Subject: [PATCH 10/11] Fix build --- README.md | 2 -- examples/sample_usage.cpp | 2 -- 2 files changed, 4 deletions(-) diff --git a/README.md b/README.md index 0129305..25c9b5b 100644 --- a/README.md +++ b/README.md @@ -26,8 +26,6 @@ The following code snippet illustrates `copyable_function`: ```cpp #include -namespace exe = beman::exemplar; - // a Callable object struct Callable { int operator()() { return 42; } diff --git a/examples/sample_usage.cpp b/examples/sample_usage.cpp index 0ad1ef2..bacc46d 100644 --- a/examples/sample_usage.cpp +++ b/examples/sample_usage.cpp @@ -1,7 +1,5 @@ #include -namespace exe = beman::copyable_function; - // a Callable object struct Callable { int operator()() { return 42; } From 6a5bdac0928ad8eda583526c11757d77b0d03a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darius=20Nea=C8=9Bu?= Date: Sat, 25 Apr 2026 16:53:27 +0300 Subject: [PATCH 11/11] Apply suggestion from @neatudarius --- examples/sample_usage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sample_usage.cpp b/examples/sample_usage.cpp index bacc46d..c4e9e7f 100644 --- a/examples/sample_usage.cpp +++ b/examples/sample_usage.cpp @@ -8,6 +8,6 @@ struct Callable { int main() { beman::copyable_function f(Callable{}); - int x = f(); + int x = f(); return 0; }