Skip to content
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: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ The following code snippet illustrates `copyable_function`:
```cpp
#include <beman/copyable_function/copyable_function.hpp>

namespace exe = beman::exemplar;

// a Callable object
struct Callable {
int operator()() { return 42; }
Expand Down
3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_executable(sample_usage sample_usage.cpp)

target_link_libraries(sample_usage PRIVATE beman::copyable_function)
13 changes: 13 additions & 0 deletions examples/sample_usage.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <beman/copyable_function/copyable_function.hpp>

// a Callable object
struct Callable {
int operator()() { return 42; }
int operator()() const noexcept { return 43; }
};

int main() {
beman::copyable_function<int()> f(Callable{});
int x = f();
return 0;
}
Loading