@@ -28,67 +28,88 @@ namespace rtl::dispatch
2828 aware_constructor (): base_t (this_t ::get_allocator())
2929 { }
3030
31- template <class ...args_t >
31+ template <class ...args_t >
3232 static Return get_allocator ()
3333 {
34- return [](const detail::FunctorId& pFunctorId, alloc pAllocType, const detail::FunctorId& pClonerId , args_t ...params )-> Return
34+ return [](alloc p_alloc_on , args_t ...params )-> Return
3535 {
36- if constexpr (sizeof ...(args_t ) == 0 && !std::is_default_constructible_v<record_t >)
37- { // default constructor, private or deleted.
38- return { error::TypeNotDefaultConstructible, RObject{} };
39- }
40- else
36+ if (p_alloc_on == alloc::Stack)
4137 {
42- if (pAllocType == alloc::Stack) {
43-
44- if constexpr (!std::is_copy_constructible_v<record_t >)
45- {
46- return { error::TypeNotCopyConstructible, RObject{} };
47- }
48- else
49- {
50- return {
51- error::None,
52- detail::RObjectBuilder<record_t >::template build<alloc::Stack>(
53- record_t (std::forward<args_t >(params)...), pClonerId, true
54- )
55- };
56- }
57- }
58- else if (pAllocType == alloc::Heap)
38+ if constexpr (std::is_copy_constructible_v<record_t >)
5939 {
6040 return {
6141 error::None,
62- detail::RObjectBuilder<record_t * >::template build<alloc::Heap >(
63- new record_t (std::forward<args_t >(params)...), pClonerId , true
42+ detail::RObjectBuilder<record_t >::template build<alloc::Stack >(
43+ record_t (std::forward<args_t >(params)...), &aware_constructor< record_t >::cloner , true
6444 )
6545 };
6646 }
6747 }
48+ else if (p_alloc_on == alloc::Heap)
49+ {
50+ return {
51+ error::None,
52+ detail::RObjectBuilder<record_t *>::template build<alloc::Heap>(
53+ new record_t (std::forward<args_t >(params)...), &aware_constructor<record_t >::cloner, true
54+ )
55+ };
56+ }
6857 return { error::EmptyRObject, RObject{} }; // dead code. compiler warning omitted.
6958 };
7059 }
7160
7261
73- static Return cloner (const detail::FunctorId& pFunctorId, const RObject& pOther, alloc pAllocOn)
62+ static Return allocator (alloc p_alloc_on)
63+ {
64+ if (!std::is_default_constructible_v<record_t >) {
65+ // default constructor, private or deleted.
66+ return { error::TypeNotDefaultConstructible, RObject{} };
67+ }
68+
69+ if (p_alloc_on == alloc::Stack)
70+ {
71+ if constexpr (std::is_copy_constructible_v<record_t >)
72+ {
73+ return {
74+ error::None,
75+ detail::RObjectBuilder<record_t >::template build<alloc::Stack>(
76+ record_t (), &aware_constructor<record_t >::cloner, true
77+ )
78+ };
79+ }
80+ }
81+ else if (p_alloc_on == alloc::Heap)
82+ {
83+ return {
84+ error::None,
85+ detail::RObjectBuilder<record_t *>::template build<alloc::Heap>(
86+ new record_t (), &aware_constructor<record_t >::cloner, true
87+ )
88+ };
89+ }
90+ return { error::EmptyRObject, RObject{} }; // dead code. compiler warning omitted.
91+ }
92+
93+
94+ static Return cloner (alloc p_alloc_on, const RObject& p_other)
7495 {
7596 if constexpr (std::is_copy_constructible_v<record_t >)
7697 {
77- const auto & srcObj = pOther .view <record_t >()->get ();
78- switch (pAllocOn )
98+ const auto & srcObj = p_other .view <record_t >()->get ();
99+ switch (p_alloc_on )
79100 {
80101 case alloc::Stack:
81102 return {
82103 error::None,
83104 detail::RObjectBuilder<record_t >::template build<alloc::Stack>(
84- record_t (srcObj), pFunctorId , true
105+ record_t (srcObj), &aware_constructor< record_t >::cloner , true
85106 )
86107 };
87108 case alloc::Heap:
88109 return {
89110 error::None,
90111 detail::RObjectBuilder<record_t *>::template build<alloc::Heap>(
91- new record_t (srcObj), pFunctorId , true
112+ new record_t (srcObj), &aware_constructor< record_t >::cloner , true
92113 )
93114 };
94115 default :
0 commit comments