30.09.2013 8:55, Emil Dotchevski:
Writing throwing destructors is discouraged, everyone knows that. But sometimes you just need it because it offers benefits compared to other approaches.
It also has drawbacks. :)
Perhaps "need" is an overstatement here, I'm sure there are other ways to do this even if we insist on using the same syntax.
If that is possible then scope(failure/success) also can be implemented in that way (without unwinding_indicator). Many have tried to do that in portable C++ with no success.
I didn't intend to create an argument, but I think that it is a mistake to open this Pandora's box, so I don't want to provide support for it in the exception library.
1. Throwing destructors is just one use case for scope(success)-like objects. But there are other use cases with scope(failure)-like objects which do not throw anything from destructor. 2. There is ISO proposal by Herb Sutter - http://isocpp.org/files/papers/N3614.pdf - for adding similar functionality: std::unwinding_exception(). 3. There is article by Jon Kalb and Dave Abrahams regarding throwing destructors: "Evil, or Just Misunderstood?" http://cpp-next.com/archive/2012/08/evil-or-just-misunderstood/ -- Evgeny Panasyuk