tags:

views:

65

answers:

2

A template template specification is like this:

template < template < class > class T >
struct MyTemplate
{
};

How Im supposed to create a total (or parcial) specialization for this template? Is this possible?

+2  A: 

A specialization of this would, for example, be:

template<>
struct MyTemplate<std::auto_ptr> {
   // ...
};
sth
+3  A: 

Like this:

#include <iostream>

template <typename T>
struct foo{};

template <typename T>
struct bar{};

template < template < class > class T >
struct MyTemplate
{
    static const bool value = false;
};

template <>
struct MyTemplate<bar>
{
    static const bool value = true;
};


int main(void)
{
    std::cout << std::boolalpha;
    std::cout << MyTemplate<foo>::value << std::endl;
    std::cout << MyTemplate<bar>::value << std::endl;
}
GMan
GMan, there is a way to enforce on MyTemplate specialization what kind ot T bar should expect?
scooterman
@scooterman: Well in your class you'd just use `bar<T>` and it'll work or not. If I'm understanding your question correctly.
GMan