STL错误将VS 6项目转换为VS2010
STL Error Converting VS 6 Project to VS2010
我正在将Visual Studio 6项目转换为Visual Studio 2010。该项目大量使用STL。转换后,编译器会给出一个错误。代码和错误如下。
#include <list>
namespace mySpace
{
template <class T>
class MyList : public std::list<T>
{
public:
typedef std::list<T>::allocator_type AllocatorType;
}
错误:错误2错误C2146:语法错误:缺少";"在标识符"AllocatorType"之前c:\myProject\mylist.h 39 1
我可以单击"allocater_type"文本并按F12,IDE会将我带到列表中的"allocateR_type"定义。
如果我删除"::allocater_type",错误就会消失。
有什么想法会导致这种情况吗?
应该是
typedef typename std::list<T>::allocator_type AllocatorType;
您必须告诉编译器allocater_type实际上是一个类型。
顺便说一句,从STL容器继承并不是一个很好的做法,因为它们没有虚拟析构函数。
将typedef行修改为:
typedef typename std::list<T>::allocator_type AllocatorType;
以声明CCD_ 1是一种类型。
相关文章:
- 防止主数据类型C++的隐式转换
- 模板参数替换失败,并且未完成隐式转换
- 努力将整数转换为链表。不知道我在这里做错了什么
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将 Qvector<uint8_t> 转换为 QString
- 如何在cuSparse中使用cusparseXcoo2csr从coo转换为csc
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中使用nlohmann从类到json的转换
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- 如何使用OpenCV将RBG图像转换为HSV,并将H、S和V值保存为C++中的3个独立图像
- 复制列表初始化的隐式转换的等级是多少
- 显式 std::exception_ptr 转换为 bool 不存在.VS2010 错误?
- o从VS6到VS2010的字符串流转换
- STL错误将VS 6项目转换为VS2010
- 'decltype':函数返回类型"T"转换为用户定义类型的"T&"(VS2010)
- 在VS2010 C++中从"双精度"转换为"int"