Closed gabyx closed 5 years ago
I am wondering why the implementation of for_each uses the CTOR in f(Args{}). The following constructs the HugeObj just to run the lambda:
for_each
f(Args{})
HugeObj
struct HugeObj { HugeObj(){ std::cout << "Huge Obj CTOR";} }; meta::for_each(meta::list<HugeObj>{}, [](auto&&r){});
Wouldnt it better to have a pointer
meta::for_each(meta::list<HugeObj>{}, [](auto*p){});
or a Functor f with a templated invoke<T> function where the implementation would look like this:
f
invoke<T>
return (void)std::initializer_list<int>{((void)f.invoke<Args>()), 0)...}, f;
Stupid question: Wrapping the thing in another transformed list meta::transform<meta::list<HugeObj>, meta::quote<meta::list>> resolves this problem...
meta::transform<meta::list<HugeObj>, meta::quote<meta::list>>
I am wondering why the implementation of
for_each
uses the CTOR inf(Args{})
. The following constructs theHugeObj
just to run the lambda:Wouldnt it better to have a pointer
or a Functor
f
with a templatedinvoke<T>
function where the implementation would look like this: