J
jukoli
Hi,
I have a function which looks like this:
template <typename Type1, typename Type2>
myfunc(void *dst, void *src);
Two variables:
int datatype1, int datatype2
datatype1 and datatype2 are coding the real type of dst and src (basic
integer types: unsigned char, int ...).
Template parameters Type and Type2 are determined by these 2 variables.
I need to call myfunc with potentially all combinations of datatype1 and
datatype2:
template <typename Type1, typename Type2>
myfunc<unsigned char, unsigned int>(void *dst, void *src);
myfunc<unsigned char, int>(void *dst, void *src);
....
A brute force solution is:
switch(datatype1) {
case UNSIGNED_CHAR:
switch(datatype2) {
case INT:
myfunc<unsigned char, int>(dst, src);
break;
...
}
...
}
I would like to avoid the use of a macro. Does somebody see a clean
solution with templates?
Thanks for your help.
I have a function which looks like this:
template <typename Type1, typename Type2>
myfunc(void *dst, void *src);
Two variables:
int datatype1, int datatype2
datatype1 and datatype2 are coding the real type of dst and src (basic
integer types: unsigned char, int ...).
Template parameters Type and Type2 are determined by these 2 variables.
I need to call myfunc with potentially all combinations of datatype1 and
datatype2:
template <typename Type1, typename Type2>
myfunc<unsigned char, unsigned int>(void *dst, void *src);
myfunc<unsigned char, int>(void *dst, void *src);
....
A brute force solution is:
switch(datatype1) {
case UNSIGNED_CHAR:
switch(datatype2) {
case INT:
myfunc<unsigned char, int>(dst, src);
break;
...
}
...
}
I would like to avoid the use of a macro. Does somebody see a clean
solution with templates?
Thanks for your help.