Why size_t arguments in template declaration need to be const?
- by ArunSaha
I can have
std::bitset< 10 > bitsetA;
or
const size_t LengthB = 20;
std::bitset< LengthB > bitsetB;
without any problem.
But, if the length is not const
size_t LengthC = 30;
std::bitset< LengthC > bitsetC; // Line 30, say
I face the following compilation error
'LengthC' cannot appear in a constant-expression
template argument 1 is invalid
What is the reason for that?
What would be the problem, for compiler and for user code, if line 30 was to be accepted? Is it because LengthC might have some alias?