好吧,我在C ++ 98中编写代码并尝试使用元编程。
我写过这种'粘合剂'
template<
template<
template<typename TArg1_1> class TArg1,
template<typename TArg2_1> class TArg2,
template<typename TArg3_1> class TArg3,
typename TArg4> class TFunction,
template<typename TArg1_1> class TArg1,
template<typename TArg2_1> class TArg2,
template<typename TArg3_1> class TArg3>
struct MetaBinder_4_3_templates_1_1_1_0 {
template <typename TArg4>
struct type : public TFunction<TArg1, TArg2, TArg3, TArg4> {};
};
接下来我要做的是绑定&#39;使用以下代码的参数:
template<
template <typename TType> class TApplier,
typename TInitialType>
struct PreserveQualifiers : public PreserveQualifier<
TypeClearVolatile,
TypeSetVolatile,
typename template <typename> MetaBinder_4_3_templates_1_1_1_0 <
PreserveQualifier,
TypeClearConst,
TypeSetConst,
TApplier>::type,
TInitialType>
{};
PreserveQualifier
声明如下:
template<
template <typename TType> class TClearer,
template <typename TType> class TSetter,
template <typename TType> class TApplier,
typename TInitialType>
struct PreserveQualifier;
但上面的代码实际上给了我这个错误(GCC 4.7,我分成行):
error: wrong number of template arguments (3, should be 4)
error: provided for '
template<
template<class TType> class TClearer,
template<class TType> class TSetter,
template<class TType> class TApplier,
class TInitialType
> struct PreserveQualifier'
我认为问题出在typename template <typename> MetaBinder_4_3_templates_1_1_1_0 <...>::type
构造语法中。实际的问题是:在这种情况下我应该如何指定依赖模板类型?