For academic purposes I'm reinventing the wheel a bit and try to write a HAL library. Now in designing it I encountered a compiler error that I do not understand.
template< class DRIVER, class PORT, class PIN >
class Instance
{
Instance(){}
public:
static void set(const bool val)
{
DRIVER::GPIOPeripheral<PORT, PIN>::set(val);
}
// ...
};
The idea is that a driver class defines the 'how' and an GPIO class defines the, well, GPIO interface abstraction.
The driver class looks something like this:
class SOC_xyz
{
SOC_xyz(){};
public:
template<class PORT, class PIN>
class GPIOPeripheral
{
static void set(const bool val){ /* ... */ };
}
};
The call in the actual code looks like this:
typedef Instance<SOC_t, PORT0_t, PIN0_t> GPIO0_0;
GPIO0_0::set(1);
Now the compiler gives me a
error: expected primary-expression before ',' token
for the Instance::set
function where the DRIVER::GPIOPeripheral<PORT, PIN>
gets called. From my understanding it tries to tell me that the class-template-member addressing part is wrong but this is beyond my C++ knowledge. Is that, what I try to do, even possible?