libstdc++
GNU C++ library
Loading...
Searching...
No Matches

◆ __median() [2/2]

template<typename _Tp, typename _Compare>
const _Tp & __gnu_cxx::__median ( const _Tp & __a,
const _Tp & __b,
const _Tp & __c,
_Compare __comp )

Find the median of three values using a predicate for comparison.

Parameters
__aA value.
__bA value.
__cA value.
__compA binary predicate.
Returns
One of a, b or c.

If {l,m,n} is some convolution of {a,b,c} such that comp(l,m) and comp(m,n) are both true then the value returned will be m. This is an SGI extension.

Definition at line 577 of file ext/algorithm.

578 {
579 // concept requirements
581 _Tp, _Tp>)
582 if (__comp(__a, __b))
583 if (__comp(__b, __c))
584 return __b;
585 else if (__comp(__a, __c))
586 return __c;
587 else
588 return __a;
589 else if (__comp(__a, __c))
590 return __a;
591 else if (__comp(__b, __c))
592 return __c;
593 else
594 return __b;
595 }
#define __glibcxx_function_requires(...)

References __glibcxx_function_requires.