Boost logo

Boost :

From: viboes (vicente.botet_at_[hidden])
Date: 2008-07-23 08:14:16


Angel Tsankov wrote:
>
> vicente.botet wrote:
>>
>>>
>>> Mathias Gaunard wrote:
>>>> Do you still provide pointer arithmetic and implicit upcasting?
>>>>
> [...]
>>>
>>> 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;
>>
> This does not compile. More precisely,
> int i = a-b; // i = 0;
> c = i; // Error: int cannot be converted to UnnullablePtr<T> (neither
> implicitly, nor explicitly)
>
>

My intent was to know how subtracting unnullable_ptr's works
See your text:
>> ... this is to say that
>> subtracting
>> unnullable_ptr's works

Thanks for clarification.

Vicente

-- 
View this message in context: http://www.nabble.com/-unnullable_ptr--Proposal-for-a-new-library-tp18585008p18609387.html
Sent from the Boost - Dev mailing list archive at Nabble.com.

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