I'm playing with templates and partial specialization, but there is one specialization I don't know how to write... I'll simplify code to make it easier to read.
Let's condiser
template <typename T>
class x
{
...
};
Usually, I can specialize like this :
class x<a_type>
{
...
};
Also works with templates types :
template <typename T>
class x<std::vector<T>>
{
...
}
Now I would like to make the specialization for a type nested in a templated class:
template <typename T>
class y
{
struct nested_type
{
y a_member;
};
...
};
// Here comes the specialization
template <typename T>
class x<y<T>::nested_type>
{
...
};
This fails. I also tried to put 'typename' before y::nested_type but it did not solved the problem. Compiler error is:
type/value mismatch at argument 1 in template parameter list for ‘template <class T> struct x’
What I want to do seems logical, but I'm not sure if it is possible. I'm using C++0x with g++-4.5. Does anybody know the correct syntax to write such specialization ?
class x<....>, notclass<....>in the first two blocks. Are you sure you've carefully typed in everything ? - Aaron McDaidxoryto simplify the problem. I did try smaller examples but the answer of Mikael seems good - I could not make small example work, and believe me, I tried a lot of things ! - neodelphitemplate<typename T> class x<typename y<T>::nested_type>rather thantemplate<typename T> class x<y<T>::nested_type>(addedtypename). - ildjarn