gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-11-01 17:40:02 31 4
gpt4 key购买 nike

当我尝试使用带有 /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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com