Make a safe type to throw in C ++

This is a theoretical question to better understand how exceptions work.

What do I need to check to make sure my class is safe? What actually happens when I throw an exception from a stack point?

For example, if I create an object on the stack, it should be destroyed when I go out of scope, but what happens when I drop this object? Is it safe to do this or do I need to create an object on the heap?

Thanks a lot!

+4
source share
1 answer

"The exception object is copied to a special place in order to survive the unpacking of the stack.

How do the exceptions highlighted on the stack go beyond their capabilities?

, , catch. . :

catch ++ - catch ?

catch ++

+7

Source: https://habr.com/ru/post/1526003/


All Articles