aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2010-02-15 16:55:20 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-02-15 16:55:20 +0000
commitd5c59224088b5d540369ec98ef287554b02bb33b (patch)
tree6b88007acd663e721ab79e23334a2988273d50c8 /libstdc++-v3
parentac447f256bc7c31c7f9b034048b5fb62183fca52 (diff)
downloadgcc-d5c59224088b5d540369ec98ef287554b02bb33b.zip
gcc-d5c59224088b5d540369ec98ef287554b02bb33b.tar.gz
gcc-d5c59224088b5d540369ec98ef287554b02bb33b.tar.bz2
stl_algo.h (__median): Move...
2010-02-15 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/stl_algo.h (__median): Move... * include/ext/algorithm: ... here, being an SGI extension. From-SVN: r156776
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog5
-rw-r--r--libstdc++-v3/include/bits/stl_algo.h68
-rw-r--r--libstdc++-v3/include/ext/algorithm68
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 <paolo.carlini@oracle.com>
+
+ * include/bits/stl_algo.h (__median): Move...
+ * include/ext/algorithm: ... here, being an SGI extension.
+
2010-02-12 Jonathan Wakely <jwakely.gcc@gmail.com>
Paolo Carlini <paolo.carlini@oracle.com>
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<typename _Tp>
- 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<typename _Tp, typename _Compare>
- 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<typename _Iterator>
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<typename _Tp>
+ 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<typename _Tp, typename _Compare>
+ 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 */