Possible Duplicate:
C++: Why can't I use float value as a template parameter?
I can define a template class:
template <int A> C {};
But I can’t define a class like:
template <float A> C{};
I think in the expression:
const float a = 10.0f;
a is a const experision, and I can use it to instantiate a float none-type template parameter
C<a> c();
but unfortunately, it’s illegal. Why?
A possible motivation for this not being allowed by the standard is that identical template parameters can appear different when treated as floats as not all floats are precisely representable. For example, would
and
be of the same type?