From: Andrey Tcherepanov (moyt63c02_at_[hidden])
Date: 2008-07-22 11:28:52
On Tue, 22 Jul 2008 05:23:48 -0600, Mathias Gaunard
> 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.
(sorry, a bit off-topic for original proposal)
Oh, no... I think the fact that Boost.Function allows storing of null
pointer ("there is no function to call") is a good thing! Otherwise it
will need to store some sort of "default" function that returns ...
seriously, what is default function would be? Say we have
bool result = f();
what would be the result case? true or false? To disallow default
constructor (no argument passes) completely will be way too limiting - it
is a encapsulation of function with pointer to function sort-of behaviour,
not reference to it.
If you completely need to be sure that there is something to call
underneath it (like to avoid thousand checks for empty value), just (wrap
and) assign some dummy function.
my 0.02 CAD
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk