开发者

Should I ever use __throw_logic_error?

开发者 https://www.devze.com 2023-04-04 21:42 出处:网络
I\'ve stumbled upon a piece of code that uses a function st开发者_StackOverflow社区d::__throw_logic_error to throw exceptions. This function is declared in functexcept.h and apparently does the same a

I've stumbled upon a piece of code that uses a function st开发者_StackOverflow社区d::__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.

0

精彩评论

暂无评论...
验证码 换一张
取 消