I'm trying to write a class which includes a variable whose type would be chosen to be the smallest possible able to contain a value.
What I mean is:
class foo {
"int type here" a;
}
I came across Automatically pick a variable type big enough to hold a specified number. Due to difficulties using the boost library, I went ahead and used the template suggestions.
That turns the code into:
template<unsigned long long T>
class foo {
SelectInteger<T>::type a;
}
However, my problem arises from the fact that the variable's size is a result of multiplying a floating point variable and integer. Therefore, what I would like to be able to do is:
template<unsigned long long T, double E>
class foo {
SelectInteger<T*E>::type a;
}
But since templates don't work with floating point variables (see here), I can't pass E
in a template. Is there some other way I can pass a variable (which should be available during compilation) to the class?