I have a parameter pack full of default constructable and then callable objects (like the ExampleFunctor
) and want to call all of them in order (left to right). If the return type is anything besides void I can use an initializer list to do this:
struct ExampleFunctor{
void operator()(){someGlobal = 4;}
};
template<typename... Ts>
struct CallThem {
void operator()(){
auto list = {Ts()()...};
}
}
however if the return type is void this trick does not work.
I could wrap all the Ts in a wrapper returning an int but that seems overkill and this code will be ultimately running on a cortex M3 with 32K of flash so the extra function call overhead of the wrapper is a pain if I compile the unit in debug mode (and debugging in release mode makes my brain hurt).
Is there a better way?