我正在尝试使用shared_ptr加速,但我似乎无法弄清楚为什么以下代码不会编译。
在头文件中,私有成员声明:
std::map<std::string, str::tr1::shared_ptr< std::vector<int> > > *_myMap;
在构造函数中,尝试实例化上述对象:
_myMap = new map<string, std::tr1::shared_ptr< vector<int> > >();
错误消息:
Test.cpp:14:68: error: cannot convert ‘std::map<std::basic_string<char>, std::tr1::shared_ptr<std::vector<int> > >*’ to ‘std::map<std::basic_string<char>, std::vector<int> >*’ in assignment
我想逐步转换我的指针,但我似乎无法弄清楚为什么上面会出现错误。任何人都可以建议吗?谢谢!
编辑:
我发现了原因。我打开了2个vim实例,其中一个是写入临时交换文件,而不是在编译时实际查看更改。感谢输入人员。
答案 0 :(得分:0)
你确定这是当前的定义吗?错误表示您的地图在标题中声明为
std::map<std::string, std::vector<int> >*
答案 1 :(得分:0)
您不能逐字发布您的代码。
您的标题必须说std::map<std::string, std::vector<int> > *_myMap;
你确定你正在建设吗?尝试新的构建。