简体   繁体   中英

Compiling boost with MSVC2015 with /std:c++latest (or C++17/N4190)

When I try to build boost with MSVC2015 with the /std:c++latest flag I get an error:

boost\algorithm\string\detail\case_conv.hpp(33): error C2143: syntax error: missing ',' before '<'

Which points to:

 // a tolower functor
 template<typename CharT>
 struct to_lowerF : public std::unary_function<CharT, CharT>

Now this seems to be due to N4190 as mentioned here: 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).

When using:

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

And using boost::ilexicographical_compare .

Its also mentioned here:

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.

So how do I get boost to compile with VC2015's /std:c++latest? Right now it appears boost isn't C++17 compatible?

Define the macro _HAS_AUTO_PTR_ETC before including any headers. For your own code, if you're using Visual Studio's build system, this is best accomplished by way of your project's Preprocessor Definitions setting . For building Boost itself, add define=_HAS_AUTO_PTR_ETC to your b2 / bjam invocation.

Other previously-standard functionality implicitly disabled by /std:c++latest can be controlled by defining the macros _HAS_FUNCTION_ASSIGN , _HAS_OLD_IOSTREAMS_MEMBERS , and _HAS_TR1_NAMESPACE . These macros are all outlined in the following blog articles:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM