File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed
ReflectionTemplateLib/detail/inc Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 44
55#include " RTLibInterface.h"
66
7- #include < streambuf>
8-
97#if defined(_MSC_VER)
108# define NOINLINE __declspec (noinline)
119#elif defined(__GNUC__)
@@ -32,7 +30,7 @@ namespace rtl_bench
3230 result = result + result;
3331 result = result + result;
3432 g_msg = pMsg;
35- return str_type (pMsg );
33+ return str_type (g_msg-> c_str () );
3634 }
3735
3836 struct Node
@@ -51,7 +49,7 @@ namespace rtl_bench
5149 result = result + result;
5250 result = result + result;
5351 g_msg = pMsg;
54- return pMsg ;
52+ return str_type (g_msg-> c_str ()) ;
5553 }
5654 };
5755
Original file line number Diff line number Diff line change 1+ #pragma once
2+
3+ #include " RObjectBuilder.hpp"
4+
5+ namespace rtl ::detail
6+ {
7+ template <class _retT , class ... _signature>
8+ struct LambdaFunction
9+ {
10+ using Invoker = _retT(*)(void * , _signature&...);
11+
12+ Invoker m_invoker = nullptr ;
13+ void * m_storage = nullptr ;
14+
15+ template <class _returnType >
16+ void init (_returnType(*pFunctor)(_signature...))
17+ {
18+ struct Holder {
19+
20+ using Functor = decltype (pFunctor);
21+ Functor m_functor;
22+
23+ Holder (Functor pFptr) : m_functor(pFptr) { }
24+ };
25+
26+ static auto holder = Holder{ pFunctor };
27+ m_storage = &holder;
28+
29+ m_invoker = +[](void * stor, _signature&... params) -> _retT {
30+
31+ auto h = static_cast <Holder*>(stor);
32+ return (h->m_functor )(params...);
33+ };
34+ }
35+
36+ _retT operator ()(_signature&... params)
37+ {
38+ return m_invoker (m_storage, params...);
39+ }
40+ };
41+ }
You can’t perform that action at this time.
0 commit comments