Jump to content
  • Advertisement
Sign in to follow this  
AAAP

Regarding static members of templates

This topic is 4546 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

I know that when you have a static member of a template, it is only static accross templates with the same type parameters, because it generates the class at compiletime (as far as my understanding of templates goes). Is there a way around this problem, so to make a static member of the template that effects all classes generated by that template, or am I stuck with using a global variable to serve this purpose.

Share this post


Link to post
Share on other sites
Advertisement
Make a non template base class with the static variable that your template inherits from. Or just use a global.

Share this post


Link to post
Share on other sites
But if the template is a subclass, won't all generated classes require vtable lookups for their functions and such by indirectly being subclasses?

Share this post


Link to post
Share on other sites
Quote:
Original post by AAAP
But if the template is a subclass, won't all generated classes require vtable lookups for their functions and such by indirectly being subclasses?


only for virtual functions. otherwise inheritance is free...

Share this post


Link to post
Share on other sites
Ahhh... sorry for my misunderstanding. So a static variable will of course have no effect on that.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!