Boost logo

Boost :

Subject: Re: [boost] [outcome] Exception safety guarantees
From: Howard Hinnant (howard.hinnant_at_[hidden])
Date: 2017-05-30 21:48:01


> On May 30, 2017, at 5:45 PM, Andrzej Krzemienski via Boost <boost_at_[hidden]> wrote:
>
> 2017-05-30 17:43 GMT+02:00 Howard Hinnant via Boost <boost_at_[hidden]>:
>
>> On May 30, 2017, at 11:30 AM, Andrzej Krzemienski via Boost <
>> boost_at_[hidden]> wrote:
>>>
>>> std::sort, apart from what it is
>>> allowed to do, is also require to produce the output range that is the
>>> permutation of the input range. Assuming no moved-from states on input,
>> if
>>> for some reason it starts to put objects in a moved-from state and then
>>> using this value for sorting further, even if moved-from state is
>>> well-ordered, you will get this moved from state in the output range, but
>>> it was not in the input range.
>>
>> Theoretically, a std::sort algorithm could move from x[i], then
>> subsequently perform x[i] < x[i], act on the return of false, and then move
>> assign a new value into x[i], and still get the right answer. I know of no
>> shipping std::sort that actually does this.
>>
>
> Yes, it could do it :)
> I guess the only purpose would be to verify if the moved-from state is well
> ordered with other values.

I was thinking more along the lines of a performance bug, much like the std::reverse implementation that did one-too-many swaps on odd-numbered ranges.

Howard




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