Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

floating point parameters in templates

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 lucky6969b   Members   

1285
Like
0Likes
Like

Posted 11 September 2012 - 02:59 AM

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

#2 Hodgman   Moderators   

50651
Like
1Likes
Like

Posted 11 September 2012 - 03:14 AM

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;

Edited by Hodgman, 11 September 2012 - 03:15 AM.


#3 Matt-D   Members   

1574
Like
1Likes
Like

Posted 16 September 2012 - 07:34 AM

See also http://stackoverflow.com/a/11518757/859774 for a more detailed explanation.




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.