YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
func_core.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/config.hpp>
4#include <yaclib/fwd.hpp>
5
6#include <type_traits>
7#include <utility>
8
9namespace yaclib::detail {
10
11template <typename Func>
12class FuncCore {
13 protected:
14 using Storage = std::decay_t<Func>;
15 using Invoke = std::conditional_t<std::is_function_v<std::remove_reference_t<Func>>, Storage, Func>;
16
17 // Func not template parameter of ctor, it's intentionally
18 explicit FuncCore(Func&& f) {
19 new (&_func.storage) Storage{std::forward<Func>(f)};
20 }
21
33};
34
35} // namespace yaclib::detail
std::decay_t< Func > Storage
Definition func_core.hpp:14
YACLIB_NO_UNIQUE_ADDRESS State _func
Definition func_core.hpp:32
std::conditional_t< std::is_function_v< std::remove_reference_t< Func > >, Storage, Func > Invoke
Definition func_core.hpp:15
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
YACLIB_NO_UNIQUE_ADDRESS Unit stub
Definition func_core.hpp:23
YACLIB_NO_UNIQUE_ADDRESS Storage storage
Definition func_core.hpp:24