Home

"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:fdi3ud$jha$1@news.datemas.de...
> Howard wrote:
>>> template<class Iterator, class F>
>>> void doSomethingWithTheMiddle(Iterator start, Iterator end, F f)
>>> {
>>> if (start != end) { // not an empty range
>>> Iterator middle = start + (start - end)/2;
>>
>> Did you mean:
>>
>> = start + (end-start)/2; // which equals (start+end)/2
>>
>> ?
>
> Yes, of course. However, the expression in your comment cannot
> be substituted. For iterators a difference is often defined,
> whereas a sum isn't. Think pointers, for example. You can
> subtract one from the other and get a ptrdiff_t value, but you
> can't add one pointer to another, it just doesn't make sense.
>

I thought that was the case. That's why I put it in a comment, not in code.
Thanks for clarifying.
-Howard

previous
next

Re: Something in the function tutorial confused me.
how to initialize list in a vector
Re: User error or g++ disambiguation bug?
Re: IDE for Python
Re: wxPython in C++ app using wxWidgets
Mimo Wszystko
Rodzic Po Ludzku
Fundacja Sloneczko
Podaruj Zycie
Krwinka