首页 > 解决方案 > C++ 中具有类模板参数的类模板的别名

问题描述

我工作,C++17我需要创建一个这样的别名:

template<const unsigned int x>
using AnotherClass_MyClass3 = MyClass<AnotherClass<x>, 3>;

以便稍后在代码中我可以调用:

AnotherClass_MyClass3(arg);  // calls the constructor

但我收到以下错误:

test.cpp:1563:13: error: alias template 'AnotherClass_MyClass3' requires template arguments; argument deduction only allowed for class templates

我该如何克服呢?

所有这一切都是因为我需要编写一个部分专门化来MyClass操作AnotherClass实例,但后者也是一个模板。
对不起,如果这是微不足道的,我是 C++ 的相对初学者。

标签: c++ooptemplates

解决方案


推荐阅读