]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libstdc++-v3/include/parallel/base.h
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / include / parallel / base.h
index e67134c653402d209aa8af15e683e06755a04a5a..91d198f5aad2422d5f32464541a1fdb7fe067b2d 100644 (file)
@@ -1,6 +1,6 @@
 // -*- C++ -*-
 
-// Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+// Copyright (C) 2007-2014 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 terms
 #ifndef _GLIBCXX_PARALLEL_BASE_H
 #define _GLIBCXX_PARALLEL_BASE_H 1
 
-#include <functional>
+#include <bits/c++config.h>
+#include <bits/stl_function.h>
 #include <omp.h>
 #include <parallel/features.h>
 #include <parallel/basic_iterator.h>
 #include <parallel/parallel.h>
 
-
 // Parallel mode namespaces.
 
 /**
  * @namespace std::__parallel
  * @brief GNU parallel code, replaces standard behavior with parallel behavior.
  */
-namespace std 
+namespace std _GLIBCXX_VISIBILITY(default) 
 { 
   namespace __parallel { } 
 }
@@ -68,7 +68,7 @@ namespace __gnu_sequential
 { 
   // Import whatever is the serial version.
 #ifdef _GLIBCXX_PARALLEL
-  using namespace std::__norm;
+  using namespace std::_GLIBCXX_STD_A;
 #else
   using namespace std;
 #endif   
@@ -113,7 +113,7 @@ namespace __gnu_parallel
    *  @param __b Second integer, to be encoded in the least-significant
    *  @c _CASable_bits/2 bits.
    *  @return value encoding @c __a and @c __b.
-   *  @see decode2
+   *  @see __decode2
    */
   inline _CASable
   __encode2(int __a, int __b)     //must all be non-negative, actually
@@ -130,7 +130,7 @@ namespace __gnu_parallel
    *  @see __encode2
    */
   inline void
-  decode2(_CASable __x, int& __a, int& __b)
+  __decode2(_CASable __x, int& __a, int& __b)
   {
     __a = (int)((__x >> (_CASable_bits / 2)) & _CASable_mask);
     __b = (int)((__x >>               0 ) & _CASable_mask);
@@ -140,13 +140,13 @@ namespace __gnu_parallel
 
   /** @brief Equivalent to std::min. */
   template<typename _Tp>
-    const _Tp&
+    inline const _Tp&
     min(const _Tp& __a, const _Tp& __b)
     { return (__a < __b) ? __a : __b; }
 
   /** @brief Equivalent to std::max. */
   template<typename _Tp>
-    const _Tp&
+    inline const _Tp&
     max(const _Tp& __a, const _Tp& __b)
     { return (__a > __b) ? __a : __b; }
 
@@ -167,7 +167,7 @@ namespace __gnu_parallel
     };
 
 
-  /** @brief Similar to std::binder1st,
+  /** @brief Similar to std::unary_negate,
    *  but giving the argument types explicitly. */
   template<typename _Predicate, typename argument_type>
     class __unary_negate
@@ -217,7 +217,7 @@ namespace __gnu_parallel
    */
   template<typename _Operation, typename _FirstArgumentType,
           typename _SecondArgumentType, typename _ResultType>
-    class binder2nd
+    class __binder2nd
     : public std::unary_function<_FirstArgumentType, _ResultType>
     {
     protected:
@@ -225,7 +225,7 @@ namespace __gnu_parallel
       _SecondArgumentType _M_value;
 
     public:
-      binder2nd(const _Operation& __x, const _SecondArgumentType& __y)
+      __binder2nd(const _Operation& __x, const _SecondArgumentType& __y)
       : _M_op(__x), _M_value(__y) { }
 
       _ResultType
@@ -262,71 +262,45 @@ namespace __gnu_parallel
 
   // Partial specialization for one type. Same as std::less.
   template<typename _Tp>
-    struct _Less<_Tp, _Tp> : public std::binary_function<_Tp, _Tp, bool>
-    {
-      bool
-      operator()(const _Tp& __x, const _Tp& __y) const
-      { return __x < __y; }
-    };
-
+    struct _Less<_Tp, _Tp>
+    : public std::less<_Tp> { };
 
   /** @brief Similar to std::plus, but allows two different types. */
-  template<typename _Tp1, typename _Tp2>
-    struct _Plus : public std::binary_function<_Tp1, _Tp2, _Tp1>
+  template<typename _Tp1, typename _Tp2, typename _Result
+          = __typeof__(*static_cast<_Tp1*>(0)
+                       + *static_cast<_Tp2*>(0))>
+    struct _Plus : public std::binary_function<_Tp1, _Tp2, _Result>
     {
-      typedef __typeof__(*static_cast<_Tp1*>(NULL)
-                        + *static_cast<_Tp2*>(NULL)) __result;
-
-      __result
+      _Result
       operator()(const _Tp1& __x, const _Tp2& __y) const
       { return __x + __y; }
     };
 
   // Partial specialization for one type. Same as std::plus.
   template<typename _Tp>
-    struct _Plus<_Tp, _Tp> : public std::binary_function<_Tp, _Tp, _Tp>
-    {
-      typedef __typeof__(*static_cast<_Tp*>(NULL)
-                        + *static_cast<_Tp*>(NULL)) __result;
-
-      __result
-      operator()(const _Tp& __x, const _Tp& __y) const
-      { return __x + __y; }
-    };
-
+    struct _Plus<_Tp, _Tp, _Tp>
+    : public std::plus<_Tp> { };
 
   /** @brief Similar to std::multiplies, but allows two different types. */
-  template<typename _Tp1, typename _Tp2>
-    struct _Multiplies : public std::binary_function<_Tp1, _Tp2, _Tp1>
+  template<typename _Tp1, typename _Tp2, typename _Result
+          = __typeof__(*static_cast<_Tp1*>(0)
+                       * *static_cast<_Tp2*>(0))>
+    struct _Multiplies : public std::binary_function<_Tp1, _Tp2, _Result>
     {
-      typedef __typeof__(*static_cast<_Tp1*>(NULL)
-                        * *static_cast<_Tp2*>(NULL)) __result;
-
-      __result
+      _Result
       operator()(const _Tp1& __x, const _Tp2& __y) const
       { return __x * __y; }
     };
 
   // Partial specialization for one type. Same as std::multiplies.
   template<typename _Tp>
-    struct _Multiplies<_Tp, _Tp> : public std::binary_function<_Tp, _Tp, _Tp>
-    {
-      typedef __typeof__(*static_cast<_Tp*>(NULL)
-                        * *static_cast<_Tp*>(NULL)) __result;
-
-      __result
-      operator()(const _Tp& __x, const _Tp& __y) const
-      { return __x * __y; }
-    };
-
-
-  template<typename _Tp, typename _DifferenceTp>
-    class _PseudoSequence;
+    struct _Multiplies<_Tp, _Tp, _Tp>
+    : public std::multiplies<_Tp> { };
 
   /** @brief _Iterator associated with __gnu_parallel::_PseudoSequence.
    *  If features the usual random-access iterator functionality.
    *  @param _Tp Sequence _M_value type.
-   *  @param _DifferenceType Sequence difference type.
+   *  @param _DifferenceTp Sequence difference type.
    */
   template<typename _Tp, typename _DifferenceTp>
     class _PseudoSequenceIterator
@@ -334,11 +308,6 @@ namespace __gnu_parallel
     public:
       typedef _DifferenceTp _DifferenceType;
 
-    private:
-      const _Tp& _M_val;
-      _DifferenceType _M_pos;
-
-    public:
       _PseudoSequenceIterator(const _Tp& __val, _DifferenceType __pos)
       : _M_val(__val), _M_pos(__pos) { }
 
@@ -351,7 +320,7 @@ namespace __gnu_parallel
       }
 
       // Post-increment operator.
-      const _PseudoSequenceIterator
+      _PseudoSequenceIterator
       operator++(int)
       { return _PseudoSequenceIterator(_M_pos++); }
 
@@ -367,20 +336,24 @@ namespace __gnu_parallel
       operator==(const _PseudoSequenceIterator& __i2)
       { return _M_pos == __i2._M_pos; }
 
-      _DifferenceType
+      bool
       operator!=(const _PseudoSequenceIterator& __i2)
       { return _M_pos != __i2._M_pos; }
 
       _DifferenceType
       operator-(const _PseudoSequenceIterator& __i2)
       { return _M_pos - __i2._M_pos; }
+
+    private:
+      const _Tp& _M_val;
+      _DifferenceType _M_pos;
     };
 
   /** @brief Sequence that conceptually consists of multiple copies of
       the same element.
       *  The copies are not stored explicitly, of course.
       *  @param _Tp Sequence _M_value type.
-      *  @param _DifferenceType Sequence difference type.
+      *  @param _DifferenceTp Sequence difference type.
       */
   template<typename _Tp, typename _DifferenceTp>
     class _PseudoSequence
@@ -392,7 +365,7 @@ namespace __gnu_parallel
       typedef _PseudoSequenceIterator<_Tp, uint64_t> iterator;
 
       /** @brief Constructor.
-       *  @param _M_val Element of the sequence.
+       *  @param __val Element of the sequence.
        *  @param __count Number of (virtual) copies.
        */
       _PseudoSequence(const _Tp& __val, _DifferenceType __count)
@@ -413,14 +386,6 @@ namespace __gnu_parallel
       _DifferenceType _M_count;
     };
 
-  /** @brief Functor that does nothing */
-  template<typename _ValueTp>
-    class _VoidFunctor
-    {
-      inline void
-      operator()(const _ValueTp& __v) const { }
-    };
-
   /** @brief Compute the median of three referenced elements,
       according to @c __comp.
       *  @param __a First iterator.
@@ -431,7 +396,7 @@ namespace __gnu_parallel
   template<typename _RAIter, typename _Compare>
     _RAIter
     __median_of_three_iterators(_RAIter __a, _RAIter __b,
-                               _RAIter __c, _Compare& __comp)
+                               _RAIter __c, _Compare __comp)
     {
       if (__comp(*__a, *__b))
        if (__comp(*__b, *__c))