From dc6991f5f4d40d4f4089cc61f0285ceffa4586f5 Mon Sep 17 00:00:00 2001 From: paolo Date: Mon, 15 Feb 2010 16:55:20 +0000 Subject: [PATCH] 2010-02-15 Paolo Carlini * include/bits/stl_algo.h (__median): Move... * include/ext/algorithm: ... here, being an SGI extension. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156776 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 5 +++ libstdc++-v3/include/bits/stl_algo.h | 68 ------------------------------------ libstdc++-v3/include/ext/algorithm | 68 ++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+), 68 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 8dace9d..3334c13 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 ed72656..6da898b 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 9b2108b..5956e24 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 */ -- 2.7.4