[Patch] libstdc++/36338
Paolo Carlini
paolo.carlini@oracle.com
Sat May 31 12:15:00 GMT 2008
Hi Chris,
> I might be going mad but:
>
>
>> while (__last - __first > 1)
>> - std::pop_heap(__first, _RandomAccessIterator(__last--));
>> + {
>> + --__last;
>> + std::__pop_heap(__first, __last, __last);
>> + }
>> }
>>
> Seeing as the original was a post-increment, shouldn't the --__last come after?
>
Well, first I think we would see that when running the testsuite ;)
Second, more seriously, I don't think so: because the original sort_heap
was passing __last to pop_heap, which, in turn, was passing __last - 1
to __pop_heap. Eventually, in the sort_heap loop __last was decremented .
In the new version, __last is decremented immediately, because this is
what __pop_heap wants, and we are done with it, the sort_heap iteration
is complete in the same way, __last decremented.
I think the two are completely equivalent.
Paolo.
More information about the Libstdc++
mailing list