编译增强与MSVC2015与/std:c++最新(或c++ 17/N4190)
Compiling boost with MSVC2015 with /std:c++latest (or C++17/N4190)
当我尝试用MSVC2015与/std:c++latest
标志构建boost时,我得到一个错误:
boostalgorithmstringdetailcase_conv.hpp(33): error C2143: syntax error: missing ',' before '<'
指向:
// a tolower functor
template<typename CharT>
struct to_lowerF : public std::unary_function<CharT, CharT>
现在这似乎是由于这里提到的N4190: https://www.visualstudio.com/en-us/news/releasenotes/vs2015-update3-vs
/std:c++latest还控制了以下old的删除功能:N4190"删除auto_ptr, random_shuffle(),和旧的东西",P0004R1"删除已弃用的io流别名",LWG 2385"function::assign allocator argument没有意义"等等非标准特性(std::tr1命名空间,有些仅限tr1)
在使用:
std::string a,b;
return boost::iequals(a,b);
使用boost::ilexicographical_compare
这里也提到了:
https://blogs.msdn.microsoft.com/vcblog/2015/06/19/c111417 -功能- vs - 2015 rtm/
Stephan T. Lavavej - MSFT Azarien: Removing auto_ptr/etc. will have positive consequences. It will prevent new code from using outdated/complicated/unsafe
机器,它将减少非专业用户之间的混淆。 (例如,不必要的unary_function/binary_function继承为通用的,因为许多用户认为STL算法/容器需要这个,而实际上只有过时的适配器才需要。)和Auto_ptr尤其不安全,因为它的"拷贝"会发生变化。构造函数从左值静默移动。
那么我如何获得boost编译与VC2015的/std:c++最新?现在看来boost不兼容c++ 17 ?
在包含任何头文件之前定义宏_HAS_AUTO_PTR_ETC
。对于您自己的代码,如果您正在使用Visual Studio的构建系统,那么最好通过项目的Preprocessor Definitions设置来完成。要构建Boost本身,将define=_HAS_AUTO_PTR_ETC
添加到b2
/bjam
调用中。
其他以前被/std:c++latest
隐式禁用的标准功能可以通过定义宏_HAS_FUNCTION_ASSIGN
、_HAS_OLD_IOSTREAMS_MEMBERS
和_HAS_TR1_NAMESPACE
来控制。这些宏在以下博客文章中都有概述:
VS 2015 Update 3中的STL修复
VS 2015 Update 2的STL是c++ 17-至今