floating point parameters in templates

Started by
1 comment, last by Matt-D 11 years, 7 months ago
In the book Game Programming Gems 1, Isensee example
The source code

template <> struct series<0.0, 0, 0>

won't compile

I understand vs2010 is a conforming compiler right now. But the whole example would become a waste unless I completely rewrite it.
What is your opinion?
Thanks
Jack
Advertisement
I don't have the book/code, but that code does look invalid -- perhaps it did work back in 2000 on old compilers. Isensee is a MS guy, so he probably wrote that code on MSVC6.
The previous C++ standards were published in 1998 and 2003, and Microsoft didn't really start adhering to them properly until ~2005.
AFAIK, you can only use types or integral values as template parameters, not floats.
On MSVC 2008 I tested and got this error:template<float f> struct Test {}; <-- error C2993: 'float' : illegal type for non-type template parameter 'f'
Test<0.0f> asdf;
See also http://stackoverflow.com/a/11518757/859774 for a more detailed explanation.

This topic is closed to new replies.

Advertisement