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

◆ __median() [1/2]

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

Find the median of three values.

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

If {l,m,n} is some convolution of {a,b,c} such that l<=m<=n then the value returned will be m. This is an SGI extension.

Definition at line 543 of file ext/algorithm.

544 {
545 // concept requirements
547 if (__a < __b)
548 if (__b < __c)
549 return __b;
550 else if (__a < __c)
551 return __c;
552 else
553 return __a;
554 else if (__a < __c)
555 return __a;
556 else if (__b < __c)
557 return __c;
558 else
559 return __b;
560 }
#define __glibcxx_function_requires(...)

References __glibcxx_function_requires.