Sign in to follow this  

floating point parameters in templates

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?

Share this post

Link to post
Share on other sites
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this