|
Boost : |
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2008-07-23 02:21:22
----- Original Message -----
From: "Angel Tsankov" <fn42551_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, July 22, 2008 9:37 PM
Subject: Re: [boost] [unnullable_ptr] Proposal for a new library
>
> Mathias Gaunard wrote:
>> Do you still provide pointer arithmetic and implicit upcasting?
>>
> Yes, implicit upcasting as well as the usual casts to void*, and T const*
> are supported (I've even written several unit tests especially to check
> the conversions). Implicit conversion from array to unnullable_ptr is also
> supported.
>
> As for pointer arithmetic, I've not yet needed it to work with
> unnullable_ptr's, so I've not considered implementing it. Nevertheless, it
> turns out that pointer arithmetic is partially supported (via the
> convertion
> operator from unnullable_ptr to C pointer); this is to say that
> subtracting
> unnullable_ptr's works, but subtracting int's from (or adding int's to)
> unnullable_ptr's doesn't yet. In fact, subtracting an int from (as well as
> adding an int to) an unnullable_ptr might result in a null pointer so the
> result need to be checked. However, the current implementation of
> unnullable_ptr is exactly as effective as a built-in C pointer (or at
> least
> allows instances of unnulable_ptr to be that effective) and I would like
> to
> keep it that way. So, subracting and adding int's will probably not be
> supported, unless a zero-overhead way is devised to guarantee
> unnullability
> of the result from these operations.
What is the expected calue of c? It is not 0?
T t;
UnnullablePtr<T> a(t);
UnnullablePtr<T> b(t);
UnnullablePtr<T> c(t);
c=a-b;
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk