@@ -10,39 +10,7 @@ namespace rtl
1010 {
1111 template <class _derivedType >
1212 template <class _recordType , class _retType , class ..._signature>
13- inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...),
14- enable_if_void<_retType> *_)
15- {
16- static std::vector<std::pair<decltype (pFunctor), std::size_t >> functorSet;
17- const auto & updateIndex = [&](const std::size_t & pIndex) {
18- functorSet.emplace_back (pFunctor, pIndex);
19- };
20- const auto & getIndex = [&]()->const std::size_t {
21- for (const auto & fptr : functorSet) {
22- if (fptr.first == pFunctor) {
23- return fptr.second ;
24- }
25- }
26- return -1 ;
27- };
28-
29- const auto functor = [=](const std::any& pTargetObj, _signature...params )->access ::RStatus
30- {
31- _recordType* target = std::any_cast<_recordType*>(pTargetObj);
32- (target->*pFunctor)(params...);
33- return access::RStatus (Error::None);
34- };
35-
36- const std::size_t & index = _derivedType::pushBack (functor, getIndex, updateIndex);
37- return detail::FunctorId (index, TypeId<_retType>::get (), TypeId<_recordType>::get (), _derivedType::getContainerId (),
38- _derivedType::template getSignatureStr<_recordType, _retType>());
39- }
40-
41-
42- template <class _derivedType >
43- template <class _recordType , class _retType , class ..._signature>
44- inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...),
45- enable_if_non_void<_retType> *_)
13+ inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...))
4614 {
4715 static std::vector<std::pair<decltype (pFunctor), std::size_t >> functorSet;
4816 const auto & updateIndex = [&](const std::size_t & pIndex) {
@@ -61,52 +29,27 @@ namespace rtl
6129 const auto functor = [=](const std::any& pTargetObj, _signature...params )->access ::RStatus
6230 {
6331 _recordType* target = std::any_cast<_recordType*>(pTargetObj);
64- const _retType& retObj = (target->*pFunctor)(params...);
65- const TypeQ& qualifier = std::is_const<_retType>::value ? TypeQ::Const : TypeQ::Mute;
66- return access::RStatus (std::make_any<_retType>(retObj), retTypeId, qualifier);
67- };
6832
69- const std::size_t & index = _derivedType::pushBack (functor, getIndex, updateIndex);
70- return detail::FunctorId (index, retTypeId, TypeId<_recordType>::get (), _derivedType::getContainerId (),
71- _derivedType::template getSignatureStr<_recordType, _retType>());
72- }
73-
74-
75- template <class _derivedType >
76- template <class _recordType , class _retType , class ..._signature>
77- inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...) const ,
78- enable_if_void<_retType> *_)
79- {
80- static std::vector<std::pair<decltype (pFunctor), std::size_t >> functorSet;
81- const auto & updateIndex = [&](const std::size_t & pIndex) {
82- functorSet.emplace_back (pFunctor, pIndex);
83- };
84- const auto & getIndex = [&]()->const std::size_t {
85- for (const auto & fptr : functorSet) {
86- if (fptr.first == pFunctor) {
87- return fptr.second ;
88- }
33+ if constexpr (std::is_same_v<_retType, void >) {
34+ (target->*pFunctor)(params...);
35+ return access::RStatus (Error::None);
36+ }
37+ else {
38+ const _retType& retObj = (target->*pFunctor)(params...);
39+ const TypeQ& qualifier = std::is_const<_retType>::value ? TypeQ::Const : TypeQ::Mute;
40+ return access::RStatus (std::make_any<_retType>(retObj), retTypeId, qualifier);
8941 }
90- return -1 ;
91- };
92-
93- const auto functor = [=](const std::any& pTargetObj, _signature...params )->access ::RStatus
94- {
95- _recordType* target = std::any_cast<_recordType*>(pTargetObj);
96- ((static_cast <const _recordType*>(target))->*pFunctor)(params...);
97- return access::RStatus (Error::None);
9842 };
9943
10044 const std::size_t & index = _derivedType::pushBack (functor, getIndex, updateIndex);
101- return detail::FunctorId (index, TypeId<_retType>:: get () , TypeId<_recordType>::get (), _derivedType::getContainerId (),
45+ return detail::FunctorId (index, retTypeId , TypeId<_recordType>::get (), _derivedType::getContainerId (),
10246 _derivedType::template getSignatureStr<_recordType, _retType>());
10347 }
10448
10549
10650 template <class _derivedType >
10751 template <class _recordType , class _retType , class ..._signature>
108- inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...) const ,
109- enable_if_non_void<_retType> *_)
52+ inline const detail::FunctorId SetupMethod<_derivedType>::addFunctor(_retType(_recordType::* pFunctor)(_signature...) const )
11053 {
11154 static std::vector<std::pair<decltype (pFunctor), std::size_t >> functorSet;
11255 const auto & updateIndex = [&](const std::size_t & pIndex) {
@@ -126,9 +69,15 @@ namespace rtl
12669 const auto functor = [=](const std::any& pTargetObj, _signature...params )->access ::RStatus
12770 {
12871 _recordType* target = std::any_cast<_recordType*>(pTargetObj);
129- const TypeQ& qualifier = std::is_const<_retType>::value ? TypeQ::Const : TypeQ::Mute;
130- const _retType& retObj = ((static_cast <const _recordType*>(target))->*pFunctor)(params...);
131- return access::RStatus (std::make_any<_retType>(retObj), retTypeId, constRetTypeId, qualifier);
72+ if constexpr (std::is_same_v<_retType, void >) {
73+ ((static_cast <const _recordType*>(target))->*pFunctor)(params...);
74+ return access::RStatus (Error::None);
75+ }
76+ else {
77+ const TypeQ& qualifier = std::is_const<_retType>::value ? TypeQ::Const : TypeQ::Mute;
78+ const _retType& retObj = ((static_cast <const _recordType*>(target))->*pFunctor)(params...);
79+ return access::RStatus (std::make_any<_retType>(retObj), retTypeId, constRetTypeId, qualifier);
80+ }
13281 };
13382
13483 const std::size_t & index = _derivedType::pushBack (functor, getIndex, updateIndex);
0 commit comments