|
Boost : |
Subject: Re: [boost] [algorithm][minmax_element] implementation question
From: Marc Glisse (marc.glisse_at_[hidden])
Date: 2013-07-04 06:54:11
On Wed, 3 Jul 2013, Michael Marcin wrote:
> I was looking at minmax_elemement to try and understand the algorithm.
>
> I noticed that the boost implementation looks significantly more complicated
> than the clang libc++ implementation.
It isn't that much longer...
> Mainly due to the potential_min_result variable that exists in the boost
> version.
http://www.boost.org/doc/libs/1_54_0/libs/algorithm/minmax/
mentions why this variable exists.
> Is there a reason for this discrepancy? Is there a bug in the clang
> implementation?
Maybe. Isn't there a test for minmax_element in the boost testsuite?
(although I don't know if it specifically checks for the very particular
case where potential_min_result is useful (2 equal consecutive values
achieving the minimum, the first one with an even index, IIRC)).
Actually, reading the standard, it uses a different definition of
minmax_element: the second element is not max_element but something like
last_max_element.
-- Marc Glisse
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk