From: Paolo Carlini Date: Mon, 15 Feb 2010 16:55:20 +0000 (+0000) Subject: stl_algo.h (__median): Move... X-Git-Tag: releases/gcc-4.5.0~773 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d5c59224088b5d540369ec98ef287554b02bb33b;p=thirdparty%2Fgcc.git stl_algo.h (__median): Move... 2010-02-15 Paolo Carlini * include/bits/stl_algo.h (__median): Move... * include/ext/algorithm: ... here, being an SGI extension. From-SVN: r156776 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8dace9d17e32..3334c13e13d9 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2010-02-15 Paolo Carlini + + * include/bits/stl_algo.h (__median): Move... + * include/ext/algorithm: ... here, being an SGI extension. + 2010-02-12 Jonathan Wakely Paolo Carlini diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index ed72656c09bc..6da898b35489 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -66,74 +66,6 @@ _GLIBCXX_BEGIN_NAMESPACE(std) - /** - * @brief Find the median of three values. - * @param a A value. - * @param b A value. - * @param c A value. - * @return One of @p a, @p b or @p c. - * - * If @c {l,m,n} is some convolution of @p {a,b,c} such that @c l<=m<=n - * then the value returned will be @c m. - * This is an SGI extension. - * @ingroup SGIextensions - */ - template - inline const _Tp& - __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) - { - // concept requirements - __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) - if (__a < __b) - if (__b < __c) - return __b; - else if (__a < __c) - return __c; - else - return __a; - else if (__a < __c) - return __a; - else if (__b < __c) - return __c; - else - return __b; - } - - /** - * @brief Find the median of three values using a predicate for comparison. - * @param a A value. - * @param b A value. - * @param c A value. - * @param comp A binary predicate. - * @return One of @p a, @p b or @p c. - * - * If @c {l,m,n} is some convolution of @p {a,b,c} such that @p comp(l,m) - * and @p comp(m,n) are both true then the value returned will be @c m. - * This is an SGI extension. - * @ingroup SGIextensions - */ - template - inline const _Tp& - __median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) - { - // concept requirements - __glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool, - _Tp, _Tp>) - if (__comp(__a, __b)) - if (__comp(__b, __c)) - return __b; - else if (__comp(__a, __c)) - return __c; - else - return __a; - else if (__comp(__a, __c)) - return __a; - else if (__comp(__b, __c)) - return __c; - else - return __b; - } - /// Swaps the median value of *__a, *__b and *__c to *__a template void diff --git a/libstdc++-v3/include/ext/algorithm b/libstdc++-v3/include/ext/algorithm index 9b2108b7f7dd..5956e24bcd0d 100644 --- a/libstdc++-v3/include/ext/algorithm +++ b/libstdc++-v3/include/ext/algorithm @@ -520,6 +520,74 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) return true; } + /** + * @brief Find the median of three values. + * @param a A value. + * @param b A value. + * @param c A value. + * @return One of @p a, @p b or @p c. + * + * If @c {l,m,n} is some convolution of @p {a,b,c} such that @c l<=m<=n + * then the value returned will be @c m. + * This is an SGI extension. + * @ingroup SGIextensions + */ + template + const _Tp& + __median(const _Tp& __a, const _Tp& __b, const _Tp& __c) + { + // concept requirements + __glibcxx_function_requires(_LessThanComparableConcept<_Tp>) + if (__a < __b) + if (__b < __c) + return __b; + else if (__a < __c) + return __c; + else + return __a; + else if (__a < __c) + return __a; + else if (__b < __c) + return __c; + else + return __b; + } + + /** + * @brief Find the median of three values using a predicate for comparison. + * @param a A value. + * @param b A value. + * @param c A value. + * @param comp A binary predicate. + * @return One of @p a, @p b or @p c. + * + * If @c {l,m,n} is some convolution of @p {a,b,c} such that @p comp(l,m) + * and @p comp(m,n) are both true then the value returned will be @c m. + * This is an SGI extension. + * @ingroup SGIextensions + */ + template + const _Tp& + __median(const _Tp& __a, const _Tp& __b, const _Tp& __c, _Compare __comp) + { + // concept requirements + __glibcxx_function_requires(_BinaryFunctionConcept<_Compare, bool, + _Tp, _Tp>) + if (__comp(__a, __b)) + if (__comp(__b, __c)) + return __b; + else if (__comp(__a, __c)) + return __c; + else + return __a; + else if (__comp(__a, __c)) + return __a; + else if (__comp(__b, __c)) + return __c; + else + return __b; + } + _GLIBCXX_END_NAMESPACE #endif /* _EXT_ALGORITHM */