following this question , I am trying to avoid copy-pasting some code related to calling all of the same-named methods of the mixins of the class BaseSensor.
Another c++11 way could be to use std::array of pointer to method e.g.:
template
class BaseSensor : public SensorType ... //to my BaseSensor class
{
void runAll(std::array&& vs) {
for (auto v: vs) {
(this->*v)();
}
}
public:
void update() {
runAll({&SensorType::update...});
}
void printStats() {
runAll({&SensorType::printStats...});
}
};