Skip to main content
gamedev.net
🔒 Locked

enable function if class has variable

Started by Dragon_Strike Jan 30, 2008 at 1:38 PM 0 replies 600+ views
Original Post
Dragon_Strike
Dragon_Strike
ive got a template class which takes structs as template parameters.. if the structs that i send in has a certain variable id like to enable a function... is there any way to do this with something similar to type-to-type mapping or boost::enable_if this is how it looks template struct elemenet { // if T::id then enable this function const T& GetByID() {} };
Sneftel
Sneftel
Actually, you can just do it. A member function of a templated class is only instantiated if it's actually called (or if you go out of your way to do other things which instantiate it, none of which you are doing).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.