Boost logo

Boost :

From: AlisdairM (alisdair.meredith_at_[hidden])
Date: 2005-10-17 17:14:46

Fernando Cacciola wrote:

> (and please!, this doesn't mean at all that optional is a pointer...
> both optional<> and pointers are models of a more fundamental concept:
> OptionalPointee or Nullable)

I dislike the term OptionalPointee as it names the concept after a
possible implementation <g> I DO like the term Nullable while the
debate remains open ;?)

Putting aside rebinding for now, one reason I would really like an
optional type would be to divorce Nullability from pointer semantics.
One reason pointers make bad Nullable types is that they reserve a
value from the valid range to represent their null value. The whole
reason to use optional< int > is to avoid that very problem.


int * px = 0;
optional< int * > ox1;
optional< int * > ox2 = px;

Is ox2 an optional value bound to a nulled value, or just a null value?
How is it different to ox1, an unbound null value?

int x = 1;
int *px = &x;
optional< int * > ox = px;

*ox == 1?
or *ox == px?

There is no reason for these questions to confuse clear minds on a
bright day, but removing the pointer interface could be clearer on the
muggy midsummer days when you are trying to get the code out before a


Boost list run by bdawes at, gregod at, cpdaniel at, john at