File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ namespace Nz
35
35
FunctionRef& operator =(FunctionRef&&) noexcept = default ;
36
36
37
37
private:
38
+ template <typename Functor> static Ret Call (void * functor, Args... args);
39
+
38
40
using Callback = Ret(*)(void * functor, Args...);
39
41
40
42
Callback m_callback;
Original file line number Diff line number Diff line change @@ -19,10 +19,7 @@ namespace Nz
19
19
FunctionRef<Ret(Args...)>::FunctionRef(F&& f) noexcept
20
20
{
21
21
m_functor = reinterpret_cast <void *>(std::addressof (f));
22
- m_callback = [](void * functor, Args... args) -> Ret
23
- {
24
- return std::invoke (*reinterpret_cast <decltype (std::addressof (f))>(functor), std::forward<Args>(args)...);
25
- };
22
+ m_callback = &Call<decltype (std::addressof (f))>;
26
23
}
27
24
28
25
template <typename Ret, typename ... Args>
@@ -37,4 +34,11 @@ namespace Nz
37
34
{
38
35
return m_functor != nullptr ;
39
36
}
37
+
38
+ template <typename Ret, typename ... Args>
39
+ template <typename Functor>
40
+ Ret FunctionRef<Ret(Args...)>::Call(void * functor, Args... args)
41
+ {
42
+ return std::invoke (*reinterpret_cast <Functor>(functor), std::forward<Args>(args)...);
43
+ }
40
44
}
You can’t perform that action at this time.
0 commit comments