Jump to content
  • Advertisement
Sign in to follow this  
AcidZombie24

template specialization based on inherit class

This topic is 3507 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 want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? i hope so. -edit- I'll have several classes inheriting SomeTag. I dont want to write the same specialization for each of them.
class SomeTag {};
class InheritSomeTag : public SomeTag {};

template <class T, class Tag=T>
struct MyClass
{
};

template <class T>
struct MyClass<T, SomeTag>
{
	typedef int isSpecialized;
};

int main()
{
	MyClass<SomeTag>::isSpecialized test1; //ok
	MyClass<InheritSomeTag>::isSpecialized test2; //how do i make this specialized w/o changing main()
	return 0;
}



[Edited by - AcidZombie24 on November 11, 2008 12:22:45 PM]

Share this post


Link to post
Share on other sites
Advertisement
Um..
template <>
struct MyClass<InheritSomeTag>
{
typedef int isSpecialized;
};
Or is there something else that complicates the matters?

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!