テンプレートテンプレートの仕様は次のようになります。
template < template < class > class T >
struct MyTemplate
{
};
このテンプレートの全体的(または部分的)な特殊化をどのように作成する必要がありますか?これは可能ですか?
テンプレートテンプレートの仕様は次のようになります。
template < template < class > class T >
struct MyTemplate
{
};
このテンプレートの全体的(または部分的)な特殊化をどのように作成する必要がありますか?これは可能ですか?
このような:
#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;
}
これの専門分野は、たとえば、次のようになります。
template<>
struct MyTemplate<std::auto_ptr> {
// ...
};