我目前正在重构一些旧代码以满足 C++14 的正确性标准,并且正在发生一些奇怪的事情。
到目前为止,此错误是唯一的,不会出现在其余代码中。我混淆了实际类型,因为它们并不重要。
在重构之前,以下代码运行良好:
namespace N {
class A {
public:
A(B* blah) : _blah(blah); //class A owns the instance of class B.
~A() { delete m_blah; m_blah = nullptr; }
//...Lots more code.
private:
B* m_blah;
};
}
我将任何必要的基于所有权的指针更改为各自的智能指针:
#include <memory>
namespace N {
class A {
public:
A(std::unique_ptr<B> blah);
~A() { /* DO NOTHING */ }
private:
std::unique_ptr<B> m_blah;
};
}
这不再有效。Intellisense 报错:
"Error: namespace "N::std" has no member unique_ptr"
在构造函数声明中。(但不是 的声明m_blah
)
....什么?为什么标准库命名空间被拉入 N?!
版本信息:
- VS2015 社区版 (RTM) 版本 14.0.23107.0 D14REL
- 开发人员命令提示符报告 cl 版本:编译器版本 19.00.23026