• Advertisement
Sign in to follow this  

floating point parameters in templates

This topic is 1951 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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:[code]template<float f> struct Test {}; <-- error C2993: 'float' : illegal type for non-type template parameter 'f'
Test<0.0f> asdf;[/code] Edited by Hodgman

Share this post


Link to post
Share on other sites
See also http://stackoverflow.com/a/11518757/859774 for a more detailed explanation.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement