diff --git a/nano/lib/function.hpp b/nano/lib/function.hpp new file mode 100644 index 000000000..a67829818 --- /dev/null +++ b/nano/lib/function.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include +#include +#include + +namespace nano +{ +// TODO: Replace with std::move_only_function in C++23 +template +auto wrap_move_only (F && f) +{ + using fn_type = decltype (std::function{ std::declval () }); + auto ptr = std::make_shared> (std::forward (f)); + return fn_type ([ptr] (auto &&... args) { + return (*ptr) (std::forward (args)...); + }); +} +} \ No newline at end of file