|
Boost : |
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-07-22 07:23:48
Angel Tsankov wrote:
> Is there any interest in a class template which acts like a pointer and
> guarantees at compile time and at no CPU or memory cost (except when a
> call to any of its methods is not inlined) that the pointer is not null?
Preventing empty or invalid cases is always good.
For example I think it's a shame Boost.Function, Boost.Any and the Boost
Smart Pointers don't do it.
As for forcing a pointer to not be empty, I suppose you're talking of
making overloads of constructor and operator= for `int' and make them
generate errors?
Do you still provide pointer arithmetic and implicit upcasting?
I personally stay away from pointers, which I associate with bad
programming.
boost::ref already provides a safe way to do what you want, and better
IMHO. It is not required to use pointers at all with it. And you *can*
get the wrapped pointer resource with get or get_pointer.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk