1.. title:: clang-tidy - modernize-use-uncaught-exceptions 2 3modernize-use-uncaught-exceptions 4==================================== 5 6This check will warn on calls to ``std::uncaught_exception`` and replace them 7with calls to ``std::uncaught_exceptions``, since ``std::uncaught_exception`` 8was deprecated in C++17. 9 10Below are a few examples of what kind of occurrences will be found and what 11they will be replaced with. 12 13.. code-block:: c++ 14 15 #define MACRO1 std::uncaught_exception 16 #define MACRO2 std::uncaught_exception 17 18 int uncaught_exception() { 19 return 0; 20 } 21 22 int main() { 23 int res; 24 25 res = uncaught_exception(); 26 // No warning, since it is not the deprecated function from namespace std 27 28 res = MACRO2(); 29 // Warning, but will not be replaced 30 31 res = std::uncaught_exception(); 32 // Warning and replaced 33 34 using std::uncaught_exception; 35 // Warning and replaced 36 37 res = uncaught_exception(); 38 // Warning and replaced 39 } 40 41After applying the fixes the code will look like the following: 42 43.. code-block:: c++ 44 45 #define MACRO1 std::uncaught_exception 46 #define MACRO2 std::uncaught_exception 47 48 int uncaught_exception() { 49 return 0; 50 } 51 52 int main() { 53 int res; 54 55 res = uncaught_exception(); 56 57 res = MACRO2(); 58 59 res = std::uncaught_exceptions(); 60 61 using std::uncaught_exceptions; 62 63 res = uncaught_exceptions(); 64 } 65