Boost logo

Boost :

From: Gabriel Dos Reis (Gabriel.Dos-Reis_at_[hidden])
Date: 2000-01-03 08:24:39


"Dave Abrahams" <abrahams_at_[hidden]> writes:

| > At 01:09 PM 12/28/99 -0600, Ed Brey wrote:
| >
| >>Here's a safe option to avoid having to choose between using the
| > implicit
| >>pointer conversion and get(): define operator! and use "if (!p)" to
| > test for
| >>null and "if (!!p)" to test for non-null. I don't like the looks of
| > it,
| >>either, but that would change over time, and even better, I'd love
| > to see how
| >>long before people start referring to the "test for non-null
| > operator". :-)
| >
| > This thread ran on so long I can't remember if anyone suggested
| > adding an is_null() member. Seems like that would be clearer than
| > adding an operator! member. I can't see asking people to write "if
| > (!!p)" to test for non-null. "if (!p.is_null())" is not quite as
| > likely to be misread or miswritten.
| >
|
| How about a free function in boost:: which was also specialized for
| std::auto_ptr and for raw pointers? That would allow some generic
| programming which would otherwise be impossible.

Beman's suggestion seems (to me) to be more reasonable from an
engeneering viewpoint.

However, requiring is_null() to be a member-function is a severe
restriction: the object it applies to must be of class-type. Which
means it won't work with builtin pointers. Do we have strong
arguments as to why we don't want it to work with builtin pointers?

Generic programming in C++ is particular in the sense that it almost
requires using non-member functions.

-- Gaby


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk