Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Because they're exception safe. But it's also possible to use them in an exception unsafe way.


well, 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 ?


Exception 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-poi...


The 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: