8 Dec
2012
8 Dec
'12
7:18 p.m.
On Sat, Dec 08, 2012 at 01:34:18PM -0500, Andrew Holden wrote:
That will work unless cptr_open() returns NULL. If I recall, if cptr_open() returns NULL, then the shared_ptr will report it is initialized correctly even though it contains a NULL pointer, and will call cptr_close (NULL) when it goes out of scope.
This is of course not necessarily an error if your deleter is documented to Do The Right Thing on nulls, like 'free', as well as simple wrappers around 'delete' and 'delete[]'. Also note that while it's "initialized correctly", operator bool-ish will still evaluate to false for a held nullptr. Implementor beware, as always. -- Lars Viklund | zao@acc.umu.se