What C++ really needs is an automated way to handle exceptions in destructors, similar to how Java does in its try-with-resources finally blocks.
While not automated, you can make use of function-try-blocks, e.g.:
struct Example { Example() = default; ~Example() try { // elease resources for this instance } catch (...) { // take care of what went wrong in the whole destructor call chain } };
Now with C++26 reflection, one could eventually generate such boilerplate.
While not automated, you can make use of function-try-blocks, e.g.:
-- https://cpp.godbolt.org/z/55oMarbqYNow with C++26 reflection, one could eventually generate such boilerplate.