Is it somehow possible to define an overloaded template function based on a non-type parameter?
following situation:
template<uint8_t> void SetupMem();
template<> void SetupMem<4>()
{ /* some code */ }
template<> void SetupMem<8>()
{ /* some code */ }
void TemplateCaller()
{
// use the plattform-specific template function at compile-time
SetupMem<sizeof(size_t)>();
}
now is it somehow possible to change the return value of SetupMem
based on the non-type parameter?
e.g.:
template<> uint32_t SetupMem<4>(){}
template<> uint64_t SetupMem<8>(){}
So that TemplateCaller()
does not explicitly calls SetupMem
with the desired template parameter (so avoiding something like: SetupMem<uint64, sizeof(size_t)>();
)? Possible solutions upto C++11 are welcome :)
size_t
, then simply usesize_t
. Note that many libraries these days come in 32 and 64 bit versions. - Walter