How to deal with noexcept in Visual Studio

前端 未结 11 1708
一整个雨季
一整个雨季 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:16

    The other way to go around is create header file and include it if necessary in your source code that should be compile by gcc, vc,or clang.

    no_except_work_around.h

    #ifndef no_except_work_around_H
    #define no_except_work_around_H
    
    #if (_MSC_VER <= 1800)
    #include 
    #define noexcept
    #endif 
    
    #endif //no_except_work_around_H
    

    =====================================================

    P.S> doesn't cover case noexcept(false) but works fine for VC2010,2012,2013, gcc 4.9

提交回复
热议问题