I am working on C++ template HAL (Hardware Abstraction Library). I trying to create register abstraction which takes register's address as a template parameter as uint32_t or as pointer, but I don't know how to do it because it causes template parameter overloading.
Incorrect example which cause redeclare parameter error:
template<uint32_t addr>
struct reg
{
...
};
template<uint32_t* addr>
struct reg
{
...
};
I thought about template specialization:
template<class T>
struct reg {};
template<>
struct reg<uint32_t>
{
...
};
template<>
struct reg<uint32_t*>
{
...
};
But I can't get the actual address value this way.
Is there any way to do this?