Boost logo

Boost :

Subject: Re: [boost] Proposal: null pointer class
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2009-06-15 15:41:49


Stewart, Robert wrote:

>> Why not make it even simpler and more general.
>>
>> template <typename T>
>> T null() {return T(); }
>>
>> int main()
>> {
>> func(NULL);
>> func(null<char*>());
                ^^^^^

> Presumably, you meant for null() to return T *. However, that
> doesn't address the overloading ambiguities that can result when
> overloading on int and char *, for example. That's why a new type is
> needed.

No, T is char* in my example. I meant the code to do exactly what I wrote. This does address the problem of pointer type overloading since you specify the pointer type and it returns the null value of that pointer type.

Regards,
luke


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