我有一个模板类:
template<class _I2CApi>
class Pca9538 {
static_assert(std::is_base_of<board::I2CApi, _I2CApi>::value, "_I2CApi must inherit from I2CApi");
typedef _I2CApi I2CApi;
和一个实现:
template<class _I2CApi>
uint8_t Pca9538<_I2CApi>::interaction(bool isRead, uint8_t cmd, uint8_t data) {
_I2CApi i2c; // No Autocompletion for board::I2CApi fields
我能以某种方式更好地描述_I2CApi
的类型为board::I2CApi
。
答案 0 :(得分:2)
您可以通过基类访问成员:
board::I2CApi& api = i2c;
在这种情况下,您的IDE应该能够自动完成board::I2CApi
的成员。