|
|
|
|
|
by cpeterso
5577 days ago
|
|
But your exception-safe C++ code soon becomes bloated with shared_ptr and unique_ptr templates and copy ctors. Almost any C++ function, overloaded operator, or some implicit temporary object's ctor can throw an exception without warning. You must use RAII everywhere for every "resource". Exception-safe RAII is pretty much an all-or-nothing affair. |
|
A common idiom I use is to typedef a class's preferred smart-pointer as ptr_t within the class namespace. Passing them around now looks like:
void some_function(my_class::ptr_t);
Exception safe, clear semantics, & no bloat.