模板专用化:不是模板
Template specialization: Is not a Template
本文关键字:专用 更新时间:2023-10-16
有人能帮我理解为什么会出现以下错误吗?
"vcr"不是模板
以下是模板类声明:
#include <iostream>
#include <complex>
using namespace std;
template<class T>
class vcr<complex <T> >
{
int length;
complex<T>* vr;
public:
vcr(int, const complex<T>* const);
vcr(int =0, complex<T> =0);
vcr(const vcr&);
~vcr() {delete[] vr;}
int size() const{ return length;}
complex<T>& operator[](int i) const { return vr[i];}
vcr& operator+=(const vcr&);
T maxnorm() const;
template<class S>
friend complex<S> dot(const vcr<complex<S> >&, const vcr<complex<S> >&);
};
template<class T> class vcr<complex <T> >{
是部分模板专用化。有一个缺失的通用变体,它(至少)看起来是这样的,并且必须在部分专业化时可见:
template<class T> class vcr;
您不需要为通用表单提供正文。
相关文章:
- .cpp和.h文件中的模板专用化声明
- 调用专用模板时出错"no matching function for call to [...]"
- 模板专用化(按容器):value_type
- 静态数据成员模板专用化的实例化点在哪里
- 特征 3 类的模板专用化
- Visual Studio 2017 不允许我创建 C++ 专用模板
- 字符串化递归的"std::vector<std::vector<...>>"而不使用部分模板函数专用化
- 具有常量引用参数的函数模板专用化
- 使用其他模板的模板专用化
- 使用专用显卡进行 OpenGL 渲染时帧速率较低
- 嵌套模板显式专用化
- 如何检查模板专用化是否是基本模板的子类?
- C++:部分模板专用化用例
- 通过依赖类型使用非类型模板参数的单类型模板参数类模板的部分专用化
- 使用对象的基类部分模板专用化对对象进行哈希处理::哈希
- 在 C++20 中是否不再允许在 std 中对程序定义类型的函数模板进行专用化?
- 为什么依赖模板类型在部分专用化中不可推导?
- 如何为静态常量模板化专用整数值分配存储
- 模板类的部分模板专用化,如 std::function
- 合并一组模板专用化