Like this:
typeArray type[2] = {uint8_t, uint16_t};
for (int i=0; i < 2; i++)
{
myFunction<type[i]>();
}
I think it is impossible to implementation, because it break some rules in C++. But I'm not sure, and I'm not familiar with the new features of C++(11 14 17 etc.). so could anyone tell me the answer?
More specific.
\\ Such as I have a template functon "PrintSecondTypeLen"
template<typename Type>PrintSecondTypeLen(unsigned int *a)
{
Type *b;
b = (Type *) a;
std::cout << *(b+1) << std::endl;
}
\\ Then suppose that I have a typeArray.
typeArray type[2] = {uint8_t, uint16_t}; \\ It's wrong, just for example.
\\ Then I use it:
unsigned int a[2] = {0x56575859, 0x46474849};
for (int i=0; i < 2; i++)
{
PrintSecondTypeLen<type[i]>(a);
}