How to detect C ++ 11 in MSVC for noexcept function?

I am working with a C ++ library. The minimum library requirements are C ++ 03. I am teaching some warnings in Visual Studio 2015 about throwing destructors:

... algparam.h(271): warning C4297: 'AlgorithmParametersBase::~AlgorithmParametersBase':
    function assumed not to throw an exception but does
... algparam.h(271): note: destructor or deallocator has
    a (possibly implicit) non-throwing exception specification

The cast was for design in the 1990s when code was written, but now it shows its age. At the moment, we are a little in the box, because we are not ready for a serious release of the version. (And it’s not as bad as it seems, prima fascia, because it protects the cast on the basis uncaught_exception).

I want to fix the problem by detecting C ++ 11 and then adding noexcept(false). I was going to hide it in the macro so that the code compiles in both C ++ 03 and C ++ 11.

The following shows how to not detect C ++ 11 in Visual Studio 2015. This does not lead to the expected compiler error:

#if (__cpluplus >= 201103L)
# error Not C++11
#endif

In addition, Microsoft suggests not offering predefined macros for locating language features. p>

How to define C ++ 11 in Visual Studio 2015?


Related, I can detect the version of the MSVC compiler through _MSC_VER. I think it will be for VS2015 _MSC_VER=1900. But this does not say anything about language opportunities.

The language functions are important if the user takes VS2015, but uses the standard C ++ level. Also, I don't have VS2013 for testing, so I'm not sure if a 1-off line such as _MSC_VER=1700is a good idea. I would rather learn if its C ++ 11 or not.


OS X Linux Clang GCC. ., , ++ 03 ++ 11? , , ++ 03 ++ 11 ? .


, Autotools, Cmake Boost. .

+4
1

VS, VS - , VS2015 ++ 03. , ( downlevel VS2015), , , .

VS .

+6

Source: https://habr.com/ru/post/1599763/


All Articles