-
Notifications
You must be signed in to change notification settings - Fork 2.7k
__cplusplus value should not be used to decide for std::unique_ptr #350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Sounds good. Let's see what you come up with. It's unlikely we'll alter the 0.y.z branch, which supports some ancient compilers, but we can probably limit ourselves to fairly recent compilers on master. |
…en-source-parsers#350: In addition to the C++ language version define __cplusplus also check _CPPLIB_VER for better Dinkumware support.
I don't understand your remark regarding ancient compilers, because my intended fix would still keep those working using Please take a look at my most recent pull request #351, which ended to become simpler than I thought originally. |
…en-source-parsers#350: In addition to the C++ language version define __cplusplus also check _CPPLIB_VER for better Dinkumware support.
Both
json_writer.cpp
andjson_reader.cpp
currently use the following preprocessor test to decide whether to usestd::unique_ptr
instead ofstd::auto_ptr
:#if __cplusplus >= 201103L
This heuristics isn't sufficient for currently existing popular C++ Standard Libraries. E.g. the Dinkumware library provided with Visual Studio 2015 does provide a conforming
std::unique_ptr
implementation, but the underlying compiler still reports a__cplusplus
value of 199711, because of a conservative policy signaling that not all parts of the C++ 11 Standard are provided. Nonetheless VS 2015 has an extremely good conformance for practical purposes, therefore I recommend to not rely alone on the value of__cplusplus
which is not necessarily a sign thatstd::unique_ptr
is available or not.I would recommend to consider a more robust characteristics to accept Libraries (such as Dinkumware) providing a valid
std::unique_ptr
, especially because as of C++11 the typestd::auto_ptr
has been formally deprecated and as of C++14 it has been completely removed from the Standard Library specification. Now Dinkumware officially allows users to disable this type by defining a the macro_HAS_AUTO_PTR_ETC
equal to0
(as described here: http://blogs.msdn.com/b/vcblog/archive/2015/04/29/c-11-14-17-features-in-vs-2015-rc.aspx) to respect this.Boost evaluates whether
_CPPLIB_VER
is either not defined or has a value less than 520 for this (plus some additional preprocessor gymnastics) which seems to be more reasonable way. I'm willing to contribute such a heuristics that would better support Visual Studio 2015 and beyond.The text was updated successfully, but these errors were encountered: