class BaseIO {
public:
...
};
tamplate <class TClass>
class InitIO : public BaseIO
{
static void AlternateInit(AlternateParameters val) {
TClass io = { val.port, val.pin };
io.SetAlternate(val.alternate);
return io.SetParameters({ Mode::Alternate });
}
static void AnalogInit(AnalogParameters val) {
TClass io = { val.port, val.pin };
return io.SetParameters({ Mode::Analog, val.pull });
}
}
class IOPort : public InitIO<IOPort> {
};
IOPort::AlternateInit({ .... });
vs
AlternateInit<IOPort>({ .... });
class IOPort : public BaseIO
{
public:
static void AnalogInit(AlternateParameters val)
{
BaseIO::AnalogInit<IOPort>(val);
}
};
IOPort::AnalogInit(...);