Reputation: 33202
template<typename T, T Min>
class LowerBoundedType {};
template<typename T> class vectorelement {};
template<> class vectorelement<Categorical> { typedef LowerBoundedType<double, 0.0> type; };
with error:
error: 'double' is not a valid type for a template constant parameter
Upvotes: 11
Views: 4749
Reputation: 473
A nontype template parameter can only one of the followings:
Therefore it cannot be a double type or a class type. In general, the primary rationale for nontype parameters is to allow sizes and range limits for containers.
Upvotes: 0
Reputation: 355009
The only numeric types valid for a nontype template parameter are integers and enumerations. So, you can't have a nontype template parameter of type double
.
Upvotes: 12