将VS 2012迁移到VS 2015后,C++项目中的Xmemory错误

use*_*929 6 c++ compiler-errors visual-studio visual-studio-2012 visual-studio-2015

我的项目在Visual Studio 2012中正常工作和编译.但是我试图在VS 2015的计算机上打开它,我得到156个错误.所有相同和全部在同一个文件中并且相同的3行:严重性代码描述项目文件行抑制状态

Error   C2338   The C++ Standard forbids containers of const elements because allocator<const T> is ill-formed. leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 585 

Error   C2535   'const long *std::allocator<_Ty>::address(const long &) noexcept const': member function already defined or declared    leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 613 

Error   C2535   'const long *std::_Wrap_alloc<std::allocator<_Ty>>::address(const long &) const': member function already defined or declared   leaf    c:\program files (x86)\microsoft visual studio 14.0\vc\include\xmemory0 846 
Run Code Online (Sandbox Code Playgroud)

我只获得了相同的3个错误,共52次,总共156次.我的代码没有出现任何错误,都是这个xmemory0文件.

Sam*_*nen 5

我假设您正在尝试将STL容器与consts 一起使用?C ++标准禁止这样做,但是Visual C ++的早期版本允许这样做。新的编译器在这方面更符合标准,并且会像您一样产生错误。

Visual Studio Connect上的更多信息

可能可以对“ <const”进行简单的“在文件中查找”,以检查整个源代码中是否存在类似内容。

  • 非常感谢!做到了。我对C ++不太了解,所以我不太确定如何搜索。它最终是两个长常量列表!非常感谢您的同伴,您的解释确实很有帮助,它不仅帮助我解决了问题,而且对我也有所了解。 (2认同)