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
3535 FunctionRef& operator =(FunctionRef&&) noexcept = default ;
3636
3737 private:
38+ template <typename Functor> static Ret Call (void * functor, Args... args);
39+
3840 using Callback = Ret(*)(void * functor, Args...);
3941
4042 Callback m_callback;
Original file line number Diff line number Diff line change @@ -19,10 +19,7 @@ namespace Nz
1919 FunctionRef<Ret(Args...)>::FunctionRef(F&& f) noexcept
2020 {
2121 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))>;
2623 }
2724
2825 template <typename Ret, typename ... Args>
@@ -37,4 +34,11 @@ namespace Nz
3734 {
3835 return m_functor != nullptr ;
3936 }
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+ }
4044}
You can’t perform that action at this time.
0 commit comments