3 ms·
The problem you mention doesn't exist, since destructors are not called when a constructor throws.
by mgaunard 3y ago
The problem you mention doesn't exist, since destructors are not called when a constructor throws.
- GrumpySloth 3y agoIf you call mmap/VirtualAlloc/open/fopen in your constructor and later it throws, you will have a resource leak, because the destructor won’t clean it up.
- mgaunard 3y agoIf you don't know how to write exception-safe code -- for which RAII is the most common idiom -- then you have exception safety issues. I don't see how that relates to the thread, other than to say exceptions in constructors are quite fundamental.