So, I want to write a class that's specialized depending on integer type (signed / unsigned and 1 / 2 / 4 / 8 bytes). I can use a template class:
template<typename T>
class Test {
private:
T internalVariable;
};
But, is there anyway to restrict this to just the integer types? So, it would cause a compiler error if someone tried to instantiate the class with a non-integer such as:
Test<float> x;
Also, I'd like this to work on an AVR-based board. So, no functions from the STL.
Additional question about these struct definitions:
Not familiar with that syntax. They seem to be creating member variables (using what look like "initial lists") of type true_type or false_type ? But there are no member variables specified in the body of the struct? And there are no constructors, which is where one normally finds initializer lists? And those "member variables" are accessed without names? The scope specifier goes straight to the "value" member?
static_assert(my_is_integral<T>::value, "T must be an integral type");