Boost logo

Boost Users :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-05-06 09:31:25


A similar concept was discussed on the Boost developer list for a class named
'optional'. The notion is the same, except that we did not discuss having a
sentinel value to denote 'null'. Instead, it was assumed that the optional<T>
class would have a 'null' flag stored in the object.

Fernando Cacciola was the author of 'optional', but I don't know what
happened to it. It never came up for review.

        Doug

On Monday 06 May 2002 07:37 am, you wrote:
> Hi All,
> Is there any need in a template wrapping an object of any type, and giving
> it an extra NULL value ? This is sometimes necessary :
> - When working with database if a column can be NULL.
> - When a value may be unspecified.
>
> The idea is to wrap an object in a class that will behave exactly like this
> object, except that it will have some extra properties :
> - The is_null() and to_null(bool) operators are added.
> - Serialization (Operators >> and <<) take into account the "NULL" string.
>
> There are three basic usage :
> - The 'null' flag can be stored in the object (Default behaviour).
> - The 'null' flag can be a special value : See specialization for pointers
> (Use of NULL special value), doubles and float (Using NotANumber NaN
> special value),
> - The 'null' flag and/or the value itself are accessed by the template,
> giving it a member function as template parameter.
>
> Please find a test program; The library itself - a single include file - is
> written and runs on GnuC and VC++ 6.
>
> Thanks.
> RC


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net