template specialization based on inherit class

Started by
1 comment, last by AcidZombie24 15 years, 5 months ago
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]
<SkilletAudio> Your framerate proves your lack of manhood
Advertisement
Um..
template <>struct MyClass<InheritSomeTag>{    typedef int isSpecialized;};
Or is there something else that complicates the matters?
Holy SH*T great answers --> http://stackoverflow.com/questions/281725/template-specialization-based-on-inherit-class
<SkilletAudio> Your framerate proves your lack of manhood

This topic is closed to new replies.

Advertisement