[algorithm][minmax_element] implementation question
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. Mainly due to the potential_min_result variable that exists in the boost version. Is there a reason for this discrepancy? Is there a bug in the clang implementation? http://llvm.org/svn/llvm-project/libcxx/trunk/include/algorithm http://www.boost.org/doc/libs/1_54_0/boost/algorithm/minmax_element.hpp
-----Original Message----- From: Boost [mailto:boost-bounces@lists.boost.org] On Behalf Of Michael Marcin Sent: Thursday, July 04, 2013 4:23 AM To: boost@lists.boost.org Subject: [boost] [algorithm][minmax_element] implementation question
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.
Mainly due to the potential_min_result variable that exists in the boost version.
Is there a reason for this discrepancy? Is there a bug in the clang implementation?
http://llvm.org/svn/llvm-project/libcxx/trunk/include/algorithm
http://www.boost.org/doc/libs/1_54_0/boost/algorithm/minmax_element.hpp
I have a faint recollection of some discussions on the Boost lists of this algorithm when it was first written. (Was it set as an exercise for the author's students?) Some googling may revive these discussions. Yours senior-momentarily, Paul --- Paul A. Bristow, Prizet Farmhouse, Kendal LA8 8AB UK +44 1539 561830 07714330204 pbristow@hetp.u-net.com
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
participants (3)
-
Marc Glisse
-
Michael Marcin
-
Paul A. Bristow