9 Aug
2013
9 Aug
'13
1:13 a.m.
On Aug 8, 2013, at 12:37 PM, Johan Engelen wrote:
On 7-8-2013 17:43, Eric Greveson wrote:
- I keep coming across code in Inkscape that could be improved with
the RAII pattern (particularly, things like:
{ Thing *t = new Thing(); ... do stuff with t ... delete t; }
When writing new code, I'd much prefer to use smart pointers, e.g.
{ std::unique_ptr<Thing> t(new Thing()); ... do stuff with t ... }
Can't comment too smartly on this but... How about { Thing t; ... do stuff with t... }
;-)
Ah, exactly.
That's the preferred, simpler solution. Avoid adding pointers whenever possible. With C++ it's possible far more often.