4 ms·
Because they're exception safe. But it's also possible to use them in an exception unsafe way.
by humanrebar 9y ago
Because they're exception safe. But it's also possible to use them in an exception unsafe way.
- jcelerier 9y agowell, that's what I don't understand with OP's > Considering how hard it is to write truly exception-safe C++ that's the default behaviour in C++ code, how hard can it be ?
- yongjik 9y agoException safety is hardly a "default behavior" of C++, considering such gems[1] as: // This is unsafe. sink( unique_ptr<widget>{new widget{}}, unique_ptr<gadget>{new gadget{}} ); // This is safe. sink( make_unique<widget>(), make_unique<gadget>() ); [1] https://herbsutter.com/2013/05/29/gotw-89-solution-smart-pointers/ https://herbsutter.com/2013/05/29/gotw-89-solution-smart-poi...
- pubby 9y agoThe default nowadays is basic exception safety, where nothing leaks but objects can get put in invalid states. Strong exception safety (rollback semantics) is still pretty hard.