How to deal with noexcept in Visual Studio

前端 未结 11 1735
一整个雨季
一整个雨季 2021-01-31 07:42

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         


        
11条回答
  •  佛祖请我去吃肉
    2021-01-31 08:20

    This check works to see if noexcept is supported:

    // Is noexcept supported?
    #if defined(__clang__) && __has_feature(cxx_noexcept) || \
        defined(__GXX_EXPERIMENTAL_CXX0X__) && __GNUC__ * 10 + __GNUC_MINOR__ >= 46 || \
        defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 180021114
    #  define NOEXCEPT noexcept
    #else
    #  define NOEXCEPT
    #endif
    

    The above works with Clang, GCC and MSVC.

提交回复
热议问题