VS2015 - "F"的匹配错误:非类型模板参数"F"的非法类型
Compliation error with VS2015 - 'F': illegal type for non-type template parameter 'F'
我们正在从VS2005迁移到VS2015,相同的代码在VS2005中编译得很好,但在VS2015中抛出一个错误"'F':非类型模板参数'F'的非法类型"
#define DLLEXPORT __declspec (dllexport)
template <class DLLEXPORT F> class DLLEXPORT QWCalloutManager {
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
有什么帮助吗??
您需要重写为:
#define DLLEXPORT __declspec (dllexport)
template <class F> class DLLEXPORT QWCalloutManager {
};
int _tmain(int argc, _TCHAR* argv[])
{
return 0;
}
没有办法说F
必须是一个导出类(除非你可以为它写一个静态断言)。你只需要在代码审查中检查它。
也许vs2005没有抱怨,但template <class __declspec (dllexport) F> class ...
不是有效的msvc++语法。
尝试从模板参数中删除DLLEXPORT
。
#define DLLEXPORT __declspec (dllexport)
template <class F> class DLLEXPORT QWCalloutManager {
};
相关文章:
- 非法,左操作数具有类型 'DWORD [29]'
- "class":非法使用此类型作为表达式 如何解决?
- 为什么基于范围类型的大括号上循环init列表是非法的c++
- 调用模板类成员时非法使用此类型作为表达式
- CPP(15): 错误 C2182:"输入":"非法使用类型"void"
- C2296:'-':非法的左操作数类型为"无符号整数"
- 排序测试模板化函数 lambda:非法使用此类型作为表达式
- 错误 C2296:'<<':非法,左操作数的类型为 'const char [41]'
- qvector.h(74):错误 C2182:'t':非法使用类型 'void'
- 错误 C2275 RHandle:非法使用此类型作为表达式
- 错误 C2296:'%':非法的左操作数在 C++ 中具有类型 'double'
- 错误:非法使用此类型作为表达式.C++
- LAMBDA 错误:类型 'void' 的条件表达式是非法的
- 任何导致非法访问的类型更改
- 为什么非模板化函数具有相同的名称和参数但不同的返回类型是非法的?(但对模板函数合法吗?)
- C++ 代码错误(非法成员初始化、'class'类型重定义、'return':无法转换)
- C++ 模板专用化 - 非类型模板参数 '__formal 的非法类型
- 无法在VS 14 CTP中使用auto声明lambda:类型为'void'的条件表达式是非法的
- 错误 C2182:'*':非法使用 'void' 类型 C:\boost_1_53_0\boost\smart_ptr\intrusive_ptr.hpp
- std::string:将此类型非法用作表达式