diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b928a6..dd9f81f 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() 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/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..366f25c --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,3 @@ +add_executable(sample_usage sample_usage.cpp) + +target_link_libraries(sample_usage PRIVATE beman::copyable_function) diff --git a/examples/sample_usage.cpp b/examples/sample_usage.cpp new file mode 100644 index 0000000..c4e9e7f --- /dev/null +++ b/examples/sample_usage.cpp @@ -0,0 +1,13 @@ +#include + +// 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; +}