7#include "../utility/utility.hpp"
8#include "../macros.hpp"
12hi_export_module(hikogui.container.functional);
15hi_export
namespace hi::inline
v1 {
17template<
typename Proto>
20template<
typename Result,
typename... Arguments>
23 using result_type = Result;
26 virtual result_type operator()(Arguments... arguments) = 0;
31template<
typename Function,
typename Proto>
34template<
typename Function,
typename Result,
typename... Arguments>
37 using result_type =
typename function<Result(Arguments...)>::result_type;
39 template<
typename Func>
40 function_impl(Func&& func) noexcept : _function(std::forward<Func>(func))
44 result_type operator()(Arguments... arguments)
override
46 return _function(
std::forward<
decltype(arguments)>(arguments)...);
53template<
typename Function,
typename Proto>
56template<
typename Function,
typename... Arguments>
59 using result_type = void;
60 using async_result_type = std::invoke_result_t<Function, Arguments...>;
62 template<
typename Func>
67 void operator()(Arguments... arguments)
override
69 if constexpr (std::is_same_v<async_result_type, void>) {
71 _function(
std::forward<
decltype(arguments)>(arguments)...);
78 _promise.set_value(_function(
std::forward<
decltype(arguments)>(arguments)...));
87 return _promise.get_future();
97template<
typename Proto,
typename Func>
98auto make_function(Func&& func)
103template<
typename Proto,
typename Func>
104auto make_async_function(Func&& func)
106 return detail::async_function_impl<std::decay_t<Func>, Proto>{std::forward<Func>(func)};
DOXYGEN BUG.
Definition algorithm_misc.hpp:20
Definition functional.hpp:18
Definition functional.hpp:32
Definition functional.hpp:54
T current_exception(T... args)