2 ms·
I also stopped writing destructors (because eventually that leads to writing move constructors); instead now just use a unique_ptr to wrap resources (covers mos
by rwbt 3y ago
I also stopped writing destructors (because eventually that leads to writing move constructors); instead now just use a unique_ptr to wrap resources (covers most of the cases) or a simple scope_exit (ala "defer"). Turns out separating ownership and lifetime really helps to write much better C++ code for me.
These simple rules coupled with great modern C++ syntax sugar like lambdas, tuples and 'auto' along with the basic data structures in it's standard library makes it a breeze.