Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I ever use __throw_logic_error?

Tags:

c++

exception

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.

like image 755
FireAphis Avatar asked Sep 15 '11 13:09

FireAphis


2 Answers

No, don't use it (unless you really know what you're doing). It's internal to the implementation (as all __ names are).

like image 143
Cat Plus Plus Avatar answered Sep 27 '22 19:09

Cat Plus Plus


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.

like image 42
Matteo Italia Avatar answered Sep 27 '22 17:09

Matteo Italia