How to restore auto_ptr in Visual Studio C++17

前端 未结 1 1137
醉酒成梦
醉酒成梦 2021-02-05 17:16

This blog page mentions that Visual Studio removes some std features:

https://blogs.msdn.microsoft.com/vcblog/2017/12/08/c17-feature-removals-and-deprecations/

I

相关标签:
1条回答
  • 2021-02-05 18:13

    In VS2017 v15.5 it is conditionally excluded, based on the project's /std:c++17 setting. You can force it to be included by forcing the underlying macro value. Two basic ways to do this:

    1. Project > Properties > C/C++ > Preprocessor > Preprocessor Definitions and add _HAS_AUTO_PTR_ETC=1. Do so for all configurations and platforms.
    2. If you use a precompiled header then you probably favor defining the macro there. Before any #includes, insert #define _HAS_AUTO_PTR_ETC 1.

    Beware of the "ETC", you'll also slurp the deprecated random_shuffle() and unary_function<>. Predicting the future is difficult, but this is probably going to work for a while to come.

    0 讨论(0)
提交回复
热议问题