|
Boost : |
From: Rian Mullins (rian.mullins_at_[hidden])
Date: 2002-05-07 18:41:39
Hi,
I am new to this list, so excuse me if this issue has been talked
about to death, but . . .
I think smart pointers should have an operator bool().
Many people use the idiom of testing a pointer in an if statement to
see if it is zero or not, i.e.:
extern MyClass* aPointer ;
...
if( aPointer )
aPointer->defenestrate() ;
And it would be nice if one could transparently replace a pointer
type in existing code with a smart_ptr type.
Of course, the implementation would be:
smart_ptr::operator bool () { return px ; }
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk