Is it possible to write class template that works for all integral types?

Viewed 1173

as you know template parameters may be types or integral values, so for example you can have

template<typename T, size_t BufferSize>
small_vector {
//...

Problem I have is that I want to write template that would work on different integral types.

So something like this:

constexpr short sa=1, sb=2, sc=3;
my_template_class1<sa,sb,sc>;
constexpr int ia=1, ib=2, ic=3;
my_template_class2<ia,ib,ic>;

In other words I know template type parameter can be int, what I want is to have a template that will work with integer template parameters for all integer types. Note that I can not just do all the computations in int64 since it would not work for uint64.

2 Answers
Related