Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Don't forget to read Tuesday's email newsletter for your chance to win a free copy of Construct 2!


floating point parameters in templates


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   -  Reputation: 624

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

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31084

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   Crossbones+   -  Reputation: 1467

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.



PARTNERS