I\'m trying to create a custom exception that derives from std::exception
and overrides what()
. At first, I wrote it like this:
class U
Add the following lines in your code in Visual Studio:
#ifdef _NOEXCEPT
#define noexcept _NOEXCEPT
#endif
The noexcept is one of the easiest "lacks" of MSVC to deal with: Just use the macro _NOEXCEPT
which under MSVC2013 is defined in yvals.h .
add the below path to the additional include directories
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include
at this location there is file called "yvals.h" which contain definition of _NOEXCEPT
It seems that the old throw()
(deprecated in C++11) works in both compilers. So I changed the code to:
virtual const char* what() const throw() override
What I've recently used is following:
#ifdef _MSC_VER
#define NOEXCEPT _NOEXCEPT
#else
#define NOEXCEPT noexcept
#endif
and then just use NOEXCEPT
everywhere.