Remove algo logic duplication Round 3

Paolo Carlini paolo.carlini@oracle.com
Mon Sep 30 16:27:00 GMT 2013


Hi,

FYI...

On 09/23/2013 10:07 PM, François Dumont wrote:
>     /// Swaps the median value of *__a, *__b and *__c under __comp to *__a
>     template<typename _Iterator, typename _Compare>
>       void
>       __move_median_first(_Iterator __a, _Iterator __b, _Iterator __c,
>   			_Compare __comp)
>       {
> -      // concept requirements
> -      __glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool,
> -	    typename iterator_traits<_Iterator>::value_type,
> -	    typename iterator_traits<_Iterator>::value_type>)
> -
> -      if (__comp(*__a, *__b))
> +      if (__comp(__a, __b))
>   	{
> -	  if (__comp(*__b, *__c))
> +	  if (__comp(__b, __c))
>   	    std::iter_swap(__a, __b);
> -	  else if (__comp(*__a, *__c))
> +	  else if (__comp(__a, __c))
>   	    std::iter_swap(__a, __c);
>   	}
> -      else if (__comp(*__a, *__c))
> +      else if (__comp(__a, __c))
>   	return;
> -      else if (__comp(*__b, *__c))
> +      else if (__comp(__b, __c))
>   	std::iter_swap(__a, __c);
>         else
>   	std::iter_swap(__a, __b);
>       }
Looks like something bad happened to this function: the changes to the 
__comp arguments can't be right. I'm going to fix it as part of applying 
Chris' patch. Please audit the rest of the patch for this kind of typo.

Paolo.



More information about the Libstdc++ mailing list