public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [v3] Move two SGI extensions to /ext
@ 2010-02-15 16:57 Paolo Carlini
  2010-02-15 17:37 ` Paolo Carlini
  0 siblings, 1 reply; 2+ messages in thread
From: Paolo Carlini @ 2010-02-15 16:57 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 79 bytes --]

Hi,

tested x86_64-linux, committed to mainline.

Paolo.

////////////////////

[-- Attachment #2: CL --]
[-- Type: text/plain, Size: 162 bytes --]

2010-02-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/stl_algo.h (__median): Move...
	* include/ext/algorithm: ... here, being an SGI extension.

[-- Attachment #3: patchlet --]
[-- Type: text/plain, Size: 4378 bytes --]

Index: include/bits/stl_algo.h
===================================================================
--- include/bits/stl_algo.h	(revision 156774)
+++ include/bits/stl_algo.h	(working copy)
@@ -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
Index: include/ext/algorithm
===================================================================
--- include/ext/algorithm	(revision 156774)
+++ include/ext/algorithm	(working copy)
@@ -520,6 +520,74 @@
       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 */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [v3] Move two SGI extensions to /ext
  2010-02-15 16:57 [v3] Move two SGI extensions to /ext Paolo Carlini
@ 2010-02-15 17:37 ` Paolo Carlini
  0 siblings, 0 replies; 2+ messages in thread
From: Paolo Carlini @ 2010-02-15 17:37 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 48 bytes --]

... oops, forgot this.

Paolo.

///////////////

[-- Attachment #2: CL_2 --]
[-- Type: text/plain, Size: 91 bytes --]

2010-02-15  Paolo Carlini  <paolo.carlini@oracle.com>

	* testsuite/ext/median.cc: Adjust.

[-- Attachment #3: patchlet_2 --]
[-- Type: text/plain, Size: 796 bytes --]

Index: testsuite/ext/median.cc
===================================================================
--- testsuite/ext/median.cc	(revision 156775)
+++ testsuite/ext/median.cc	(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2005, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2005, 2009, 2010 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -17,7 +17,7 @@
 
 // median - SGI extension
 
-#include <algorithm>
+#include <ext/algorithm>
 #include <testsuite_hooks.h>
 
 bool pred(const int& l, const int& r)
@@ -25,9 +25,9 @@
   return l<r;
 }
 
-using std::__median;
+using __gnu_cxx::__median;
 
-int main(void)
+int main()
 {
   const int i=1;
   const int j=2;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-15 17:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-15 16:57 [v3] Move two SGI extensions to /ext Paolo Carlini
2010-02-15 17:37 ` Paolo Carlini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).