Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-07-30 12:01:27


Anis Benyelloul wrote:

> I just had a quick look! I seems that their concern was about
> redefining NULL
> itself, not about a NULL replacement as such. By the way, I didn't
> redefine
> NULL.

The problem was indeed mostly about me redefining NULL (which I admit
now was a bad idea), but there is still a problem with the template
based null that was shown to me by Eric Niebler (edited to make it look
more like a real world example):

template < typename Type >
struct SmartPtr
{
    SmartPtr ( Type * )
    {
    }
};

void Bar ( SmartPtr < int > )
{
}

void Test ( )
{
    Bar ( boost::null ); // fails, requires two user defined conversions
}

I suppose SmartPtr could add a constructor taking boost::null_type, but
that seems horribly redundant, especially when passing 0 for null would
still work perfectly without the need for another constructor. Any
ideas for solving this use case?

-Jason


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