c++ - 使用/std :c++latest (or C++17/N4190) 使用 MSVC2015 编译 boost

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

当我尝试使用带有 /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 also controls the removal of the following old features: N4190 "Removing auto_ptr, random_shuffle(), And Old Stuff", P0004R1 "Removing Deprecated Iostreams Aliases", LWG 2385 "function::assign allocator argument doesn't make sense", and various non-Standard features (the std::tr1 namespace, some TR1-only machinery, and the std::identity struct).

使用时:

 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 不兼容 C++17?

最佳答案

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

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

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

关于c++ - 使用/std :c++latest (or C++17/N4190) 使用 MSVC2015 编译 boost ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39363720/

相关文章:

Java 行 IO 与 C++ IO?

c++ - 带约束的可变参数模板的 'requires' 表达式的语法是什么?

c++ - 如何禁用 QDoubleSpinBox 中的向上/向下按钮

c++ - 在最佳时间从 _variant_t 获取 char*

c++ - shared boost::shared_ptr<> 变量是线程安全的吗?

ssl - 如何获取类型为 boost::asio::ssl::stream<boost::asio::ip::tcp::socket> 的套接字的远程端点的 IP 地址

c++ - GDB 显示文件名 : no cpp file

c++ - 在 C++ 中消除名称冲突的最佳方法

c++ - 使用 HDF5 C++ 编写动态大小的复合类型数据集

c++ - Xcode 4.5.2 中的 boost::regex 链接问题