c++ - Why is double not allowed as a non-type template parameter? -
this question has answer here:
in 2003 - yes, 2003 - vandervoorde , josuttis wrote in book "c++ templates" (p. 40):
not being able use floating-point literals (and simple constant floating-point expressions) template arguments has historical reasons. because there no serious technical challenges, may supported in future versions of c++.
but still doesn't work, under c++11:
template<double d> //error void foo() {} why not added?
i had assumed had matching implementations against each other. these 2 instances same or different:
template class foo<10./3.> template class foo<1./3 * 10.> they may not generate same double-precision representation, compiler might think of them different classes. couldn't assign them each other, etc.
Comments
Post a Comment