[compute] 09/49: Fix violations of Boost min/max guidelines

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Fri Dec 18 17:58:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository compute.

commit 350f2c93a8560df76e66da661a5d58e09f5e272a
Author: Jakub Szuppe <j.szuppe at gmail.com>
Date:   Thu Jul 16 19:06:55 2015 +0200

    Fix violations of Boost min/max guidelines
---
 example/simple_moving_average.cpp                         | 4 ++--
 include/boost/compute/algorithm/accumulate.hpp            | 4 ++--
 include/boost/compute/random/normal_distribution.hpp      | 4 ++--
 include/boost/compute/random/uniform_int_distribution.hpp | 2 +-
 perf/perf_accumulate.cpp                                  | 2 +-
 perf/perf_saxpy.cpp                                       | 2 +-
 perf/perf_sort.cpp                                        | 2 +-
 perf/perf_tbb_merge.cpp                                   | 2 +-
 test/test_accumulate.cpp                                  | 6 +++---
 9 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/example/simple_moving_average.cpp b/example/simple_moving_average.cpp
index 9e12697..ca76809 100644
--- a/example/simple_moving_average.cpp
+++ b/example/simple_moving_average.cpp
@@ -63,8 +63,8 @@ bool check_results(const std::vector<float>& values, const std::vector<float>& s
     bool res = true;
     for(int idx = 0 ; idx < size ; ++idx)
     {
-        int start = std::max(idx - semiWidth,0);
-        int end = std::min(idx + semiWidth,size-1);
+        int start = (std::max)(idx - semiWidth,0);
+        int end = (std::min)(idx + semiWidth,size-1);
         float res = 0;
         for(int j = start ; j <= end ; ++j)
         {
diff --git a/include/boost/compute/algorithm/accumulate.hpp b/include/boost/compute/algorithm/accumulate.hpp
index 9b46f72..328420a 100644
--- a/include/boost/compute/algorithm/accumulate.hpp
+++ b/include/boost/compute/algorithm/accumulate.hpp
@@ -85,13 +85,13 @@ BOOST_PP_SEQ_FOR_EACH(
 template<class T>
 inline bool can_accumulate_with_reduce(T init, min<T>)
 {
-    return init == std::numeric_limits<T>::max();
+    return init == (std::numeric_limits<T>::max)();
 }
 
 template<class T>
 inline bool can_accumulate_with_reduce(T init, max<T>)
 {
-    return init == std::numeric_limits<T>::min();
+    return init == (std::numeric_limits<T>::min)();
 }
 
 #undef BOOST_COMPUTE_DETAIL_DECLARE_CAN_ACCUMULATE_WITH_REDUCE
diff --git a/include/boost/compute/random/normal_distribution.hpp b/include/boost/compute/random/normal_distribution.hpp
index 5120212..d025fae 100644
--- a/include/boost/compute/random/normal_distribution.hpp
+++ b/include/boost/compute/random/normal_distribution.hpp
@@ -62,13 +62,13 @@ public:
     }
 
     /// Returns the minimum value of the distribution.
-    result_type min() const
+    result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const
     {
         return -std::numeric_limits<RealType>::infinity();
     }
 
     /// Returns the maximum value of the distribution.
-    result_type max() const
+    result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const
     {
         return std::numeric_limits<RealType>::infinity();
     }
diff --git a/include/boost/compute/random/uniform_int_distribution.hpp b/include/boost/compute/random/uniform_int_distribution.hpp
index 86fa146..92e8b33 100644
--- a/include/boost/compute/random/uniform_int_distribution.hpp
+++ b/include/boost/compute/random/uniform_int_distribution.hpp
@@ -40,7 +40,7 @@ public:
     /// Creates a new uniform distribution producing numbers in the range
     /// [\p a, \p b].
     explicit uniform_int_distribution(IntType a = 0,
-                                      IntType b = std::numeric_limits<IntType>::max())
+                                      IntType b = (std::numeric_limits<IntType>::max)())
         : m_a(a),
           m_b(b)
     {
diff --git a/perf/perf_accumulate.cpp b/perf/perf_accumulate.cpp
index ba31ff5..bd4276e 100644
--- a/perf/perf_accumulate.cpp
+++ b/perf/perf_accumulate.cpp
@@ -58,7 +58,7 @@ void tune_accumulate(const compute::vector<T>& data,
     const compute::uint_ tpbs[] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024 };
     const compute::uint_ vpts[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
-    double min_time = std::numeric_limits<double>::max();
+    double min_time = (std::numeric_limits<double>::max)();
     compute::uint_ best_tpb = 0;
     compute::uint_ best_vpt = 0;
 
diff --git a/perf/perf_saxpy.cpp b/perf/perf_saxpy.cpp
index f944ebc..7370b45 100644
--- a/perf/perf_saxpy.cpp
+++ b/perf/perf_saxpy.cpp
@@ -76,7 +76,7 @@ void tune_saxpy(const compute::vector<T>& x,
     const compute::uint_ tpbs[] = { 4, 8, 16, 32, 64, 128, 256, 512, 1024 };
     const compute::uint_ vpts[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
 
-    double min_time = std::numeric_limits<double>::max();
+    double min_time = (std::numeric_limits<double>::max)();
     compute::uint_ best_tpb = 0;
     compute::uint_ best_vpt = 0;
 
diff --git a/perf/perf_sort.cpp b/perf/perf_sort.cpp
index cc56081..458203e 100644
--- a/perf/perf_sort.cpp
+++ b/perf/perf_sort.cpp
@@ -59,7 +59,7 @@ void tune_sort(const std::vector<T>& data,
 
     const compute::uint_ tpbs[] = { 32, 64, 128, 256, 512, 1024 };
 
-    double min_time = std::numeric_limits<double>::max();
+    double min_time = (std::numeric_limits<double>::max)();
     compute::uint_ best_tpb = 0;
 
     for(size_t i = 0; i < sizeof(tpbs) / sizeof(*tpbs); i++){
diff --git a/perf/perf_tbb_merge.cpp b/perf/perf_tbb_merge.cpp
index 476bf71..27927c6 100644
--- a/perf/perf_tbb_merge.cpp
+++ b/perf/perf_tbb_merge.cpp
@@ -17,7 +17,7 @@ struct ParallelMergeRange {
     Iterator out;               // where to put merged sequence
     bool empty()   const {return (end1-begin1)+(end2-begin2)==0;}
     bool is_divisible() const {
-        return std::min( end1-begin1, end2-begin2 ) > grainsize;
+        return (std::min)( end1-begin1, end2-begin2 ) > grainsize;
     }
     ParallelMergeRange( ParallelMergeRange& r, split ) {
         if( r.end1-r.begin1 < r.end2-r.begin2 ) {
diff --git a/test/test_accumulate.cpp b/test/test_accumulate.cpp
index cde695c..81e7a92 100644
--- a/test/test_accumulate.cpp
+++ b/test/test_accumulate.cpp
@@ -211,7 +211,7 @@ BOOST_AUTO_TEST_CASE(min_and_max)
 
     BOOST_COMPUTE_FUNCTION(int2_, min_and_max, (int2_ accumulator, const int value),
     {
-        return (int2)(min(accumulator.x, value), max(accumulator.y, value));
+        return (int2)((min)(accumulator.x, value), (max)(accumulator.y, value));
     });
 
     int2_ result = boost::compute::accumulate(
@@ -230,12 +230,12 @@ BOOST_AUTO_TEST_CASE(min_max)
     using ::boost::compute::max;
 
     float min_value = boost::compute::accumulate(
-        vec.begin(), vec.end(), std::numeric_limits<float>::max(), min<float>(), queue
+        vec.begin(), vec.end(), (std::numeric_limits<float>::max)(), min<float>(), queue
     );
     BOOST_CHECK_EQUAL(min_value, 0.1f);
 
     float max_value = boost::compute::accumulate(
-        vec.begin(), vec.end(), std::numeric_limits<float>::min(), max<float>(), queue
+        vec.begin(), vec.end(), (std::numeric_limits<float>::min()), max<float>(), queue
     );
     BOOST_CHECK_EQUAL(max_value, 9.6f);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/compute.git



More information about the debian-science-commits mailing list