【问题标题】:Compiling boost with MSVC2015 with /std:c++latest (or C++17/N4190)使用 /std:c++latest(或 C++17/N4190)使用 MSVC2015 编译 boost
【发布时间】:2017-01-14 18:43:00
【问题描述】:

当我尝试使用带有 /std:c++latest 标志的 MSVC2015 构建提升时,我收到一个错误:

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 分配器参数没有意义”,以及各种 非标准特性(std::tr1 命名空间,一些 TR1-only 机器和 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

机械,它将减少非专家用户之间的混淆。 (对于 例如,不必要的 unary_function/binary_function 继承是 常见,因为许多用户认为 STL 算法/容器 需要这个,而实际上只有过时的适配器才需要。)和 auto_ptr 特别是不安全的,因为它的变异“副本” 构造函数默默地从左值移动。

那么,如何使用 VC2015 的 /std:c++latest 进行编译?现在看来 boost 不兼容 C++17?

【问题讨论】:

标签: c++ visual-c++ boost visual-studio-2015 c++17


【解决方案1】:

在包含 any 标头之前定义宏 _HAS_AUTO_PTR_ETC。对于您自己的代码,如果您使用 Visual Studio 的构建系统,最好通过项目的Preprocessor Definitions setting 来完成。要构建 Boost 本身,请将 define=_HAS_AUTO_PTR_ETC 添加到您的 b2/bjam 调用中。

可以通过定义宏 _HAS_FUNCTION_ASSIGN_HAS_OLD_IOSTREAMS_MEMBERS_HAS_TR1_NAMESPACE 来控制由 /std:c++latest 隐式禁用的其他先前标准功能。这些宏都在以下博客文章中进行了概述:

STL Fixes In VS 2015 Update 3
VS 2015 Update 2’s STL is C++17-so-far Feature Complete

【讨论】:

    猜你喜欢
    • 2019-07-26
    • 2021-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-17
    • 1970-01-01
    • 2018-07-04
    • 1970-01-01
    相关资源
    最近更新 更多