I've stumbled upon a piece of code that uses a function std::__throw_logic_error to throw exceptions. This function is declared in functexcept.h and apparently does the same as throw logic_error(...). Is there a difference? What is the function for? When, if at all, should I prefer it?
Thank you.
No, don't use it (unless you really know what you're doing). It's internal to the implementation (as all __ names are).
In general, you shouldn't use it.
The two underscores at the beginning of the name are an indication that it's a compiler-specific addition, and probably it's not even meant for "public" use, but just as a helper for internals of the standard library (I suspect that it's there to support e.g. using the library without exceptions, but I'm just guessing).
Just use throw.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With