使用MSVC2015编译带有/std:c++latest(或C++17/N4190)选项的Boost库

8

当我尝试使用/std:c++latest标志在MSVC2015上构建boost时,会出现错误:

boost\algorithm\string\detail\case_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 还控制以下旧特性的删除:N4190“删除auto_ptr,random_shuffle()和旧内容”,P0004R1“删除已弃用的Iostreams别名”,LWG 2385“function::assign allocator argument doesn't make sense”,以及一些非标准功能(std::tr1命名空间,一些仅限于TR1的机制和std::identity结构)。

当使用:

 std::string a,b;
 return boost::iequals(a,b);

使用 boost::ilexicographical_compare

这里也提到了:

https://blogs.msdn.microsoft.com/vcblog/2015/06/19/c111417-features-in-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

machinery, and it will reduce confusion among non-expert users. (For example, unnecessary unary_function/binary_function inheritance is common, because many users thought that STL algorithms/containers required this, when in fact only the outdated adapters did.) And auto_ptr in particular is unsafe, because its mutating "copy" constructor silently moves from lvalues.

那么,我该如何使用VC2015的 /std:c++latest 编译boost呢?目前看来,Boost似乎不兼容C++17?


报告问题。http://www.boost.org/development/bugs.html .. https://svn.boost.org/trac/boost/newticket - GrafikRobot
1个回答

9
在包含任何头文件之前定义宏_HAS_AUTO_PTR_ETC。如果您正在使用Visual Studio的构建系统编写自己的代码,则最好通过项目的预处理器定义设置来完成此操作。对于构建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的特性

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接