<p>I want to make this specialized w/o changing main. Is it possible to specialize something based on its base class? I hope so.</p>

<p>-edit-</p>

<p>I'll have several classes that inherit from SomeTag. I don't want to write the same specialization for each of them.</p>

<pre><code>class SomeTag {};
class InheritSomeTag : public SomeTag {};

template &lt;class T, class Tag=T&gt;
struct MyClass
{
};

template &lt;class T&gt;
struct MyClass&lt;T, SomeTag&gt;
{
    typedef int isSpecialized;
};

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

In your case, the only way that I see would be to explicitly specialize
```
MyClass
```
for
```
InheritSomeTag
```
. However, the
SeqAn paper
proposes a mechanism called “template sublassing” that does what you want – albeit with a different inheritance syntax, so the code isn't compatible with your current
```
main
```
function.
```
```
// Base class
template <typename TSpec = void>
class SomeTag { };

// Type tag, NOT part of the inheritance chain
template <typename TSpec = void>
struct InheritSomeTag { };

// Derived class, uses type tag
template <typename TSpec>
class SomeTag<InheritSomeTag<TSpec> > : public SomeTag<void> { };

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

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

int main()
{
    MyClass<SomeTag<> >::isSpecialized test1; //ok
    MyClass<SomeTag<InheritSomeTag<> > >::isSpecialized test2; //ok
}
```
```
This certainly looks strange and is very cumbersome but it allows a true inheritance mechanism with polymorphic functions that is executed at compile time. If you want to see this in action, have a look at some
SeqAn examples
.
That being said, I believe that SeqAn is a special case and not many applications would profit from this extremely difficult syntax (deciphering SeqAn-related compiler errors is a real pain in the *ss!)