I managed to make it with a trick. Though I'm not sure it will work as expected independently of compiler implementation. Please post if you see any caveat.
First, add a trivial member to struct, at first position, which must always have the same name (busin this case):
//list of sensors with a member for each sensor
typedef struct {
cOneSensor_ini bus = cOneSensor_ini("A4", 0); // <<--- HERE fixed member
cOneSensor_f A4_temp1 = cOneSensor_f ("A4t1", 0x1234);
//... more sensor of different types
}Sensor_list_4_s;
Now you can use this first member with known name as a pointer to the whole struct: sensors_array = &this->bus;:
template <typename T>
class cSensorsList: public T
{
//...
public:
cSensorsList(int bus_code):bus_code(bus_code)
{
nSensors = sizeof(T);
p_sensors_array = &this->bus; // <<--- HERE get pointer to template members
}
void update(void) {/*...*/}
};
bus member, the compiler complains.bus member, but not the first, the compiler doesn't complains, but code doesn't work as expected. Though this would be weird...But I'm pretty sure (or I wish) there should be a more elegant solution.