A Lippincott function is a function which converts an exception into a return code that can be safely handled in a callback from another language which did not support exceptions, such as C. Such functions, because they deliberately use
throw with no argument, thereby rethrowing the most recently caught exception, cannot be called outside the context of a
I am wondering if modern C++ (c++17 or c++20) has any declaration mechanism for specifically identifying such functions, and ensuring that a function is only ever called from the context of a
catch block (or from the context of another such function), generating a compile time error if it is called from any other context.
There is no way to tell the compiler that a particular function should only be called from a
You can, however, call
std::current_exception() from within your Lippincott function to determine if there currently an exception being handled. If this returns a
nullptr then there is no exception active. You can then handle this at runtime by triggering an assert and/or having your function return (and not use throw).
Answered By – 1201ProgramAlarm
Answer Checked By – Cary Denson (BugsFixing Admin)