C++ 如何将模板转换为C+之前的模板+;11

C++ 如何将模板转换为C+之前的模板+;11,c++,templates,c++03,template-templates,C++,Templates,C++03,Template Templates,由我编写的模板触发,该模板允许将模板转换为具有不同参数的模板: template< template <int A,char B,bool> typename T> struct Add_true { template <int A,char B> using type = T<A,B,true>; }; 但是现在Add\u-true\u-to\u-Foo::type不是一个模板,如果没有C++11,我一点也不知道如何编写一个Add\u-

由我编写的模板触发,该模板允许将模板转换为具有不同参数的模板:

template< template <int A,char B,bool> typename T>
struct Add_true {
    template <int A,char B> using type = T<A,B,true>;
};
但是现在
Add\u-true\u-to\u-Foo::type
不是一个模板,如果没有C++11,我一点也不知道如何编写一个
Add\u-true
,它不仅适用于
Foo
,而且也适用于

template <int A,char B, bool C> struct Bar{};
模板结构条{};
也许我错过了一些明显的东西。我的问题是


是否可以在C++11之前编写与上述
Add_true
等价的代码?

没有严格的C++11模板等价物, 但您可以添加额外的模板类来模拟行为,并使用不同的语法:

template <template <int, char, bool> class C>
struct Add_true {
    template <int A, char B>
    struct apply
    {
        typedef T<A, B, true> type;
    }
};
模板
结构添加_true{
样板
结构应用
{
T型;
}
};
使用方法:

template <int A,char B, bool C> struct Foo{};

typedef Add_true<Foo>::apply<42, '*'>::type my_type; // Foo<42, '*', true>
模板结构Foo{};
typedef Add_true::apply::type my_type;//福

没有严格等效的C++11模板, 但您可以添加额外的模板类来模拟行为,并使用不同的语法:

template <template <int, char, bool> class C>
struct Add_true {
    template <int A, char B>
    struct apply
    {
        typedef T<A, B, true> type;
    }
};
模板
结构添加_true{
样板
结构应用
{
T型;
}
};
使用方法:

template <int A,char B, bool C> struct Foo{};

typedef Add_true<Foo>::apply<42, '*'>::type my_type; // Foo<42, '*', true>
模板结构Foo{};
typedef Add_true::apply::type my_type;//福

继承将是C++03的方式

template< template <int A,char B,bool> typename T>
struct Add_true {
    template <int A,char B>
    struct type : T<A,B,true> {};
};
template