From 2d6f07011fffde69f57d3cd751c8dd9414ff0e95 Mon Sep 17 00:00:00 2001 From: andreacassioli Date: Sun, 25 Oct 2026 17:40:38 +0100 Subject: [PATCH 1/2] use std min/max in topology.hpp --- include/boost/graph/topology.hpp | 52 +++++++++++--------------------- 1 file changed, 18 insertions(+), 34 deletions(-) diff --git a/include/boost/graph/topology.hpp b/include/boost/graph/topology.hpp index e1117cae8..251e380fc 100644 --- a/include/boost/graph/topology.hpp +++ b/include/boost/graph/topology.hpp @@ -12,7 +12,6 @@ #include #include // For BOOST_STATIC_CONSTANT -#include #include #include #include @@ -188,19 +187,17 @@ template < std::size_t Dims > class convex_topology point pointwise_min(point a, point b) const { - BOOST_USING_STD_MIN(); point result; for (std::size_t i = 0; i < Dims; ++i) - result[i] = min BOOST_PREVENT_MACRO_SUBSTITUTION(a[i], b[i]); + result[i] = (std::min)(a[i], b[i]); return result; } point pointwise_max(point a, point b) const { - BOOST_USING_STD_MAX(); point result; for (std::size_t i = 0; i < Dims; ++i) - result[i] = max BOOST_PREVENT_MACRO_SUBSTITUTION(a[i], b[i]); + result[i] = (std::max)(a[i], b[i]); return result; } @@ -253,27 +250,22 @@ class hypercube_topology : public convex_topology< Dims > point_type bound(point_type a) const { - BOOST_USING_STD_MIN(); - BOOST_USING_STD_MAX(); point_type p; for (std::size_t i = 0; i < Dims; ++i) - p[i] = min BOOST_PREVENT_MACRO_SUBSTITUTION( - scaling, max BOOST_PREVENT_MACRO_SUBSTITUTION(-scaling, a[i])); + p[i] = (std::min)( + scaling, (std::max)(-scaling, a[i])); return p; } double distance_from_boundary(point_type a) const { - BOOST_USING_STD_MIN(); - BOOST_USING_STD_MAX(); #ifndef BOOST_NO_STDC_NAMESPACE using std::abs; #endif BOOST_STATIC_ASSERT(Dims >= 1); double dist = abs(scaling - a[0]); for (std::size_t i = 1; i < Dims; ++i) - dist = min BOOST_PREVENT_MACRO_SUBSTITUTION( - dist, abs(scaling - a[i])); + dist = (std::min)(dist, abs(scaling - a[i])); return dist; } @@ -330,10 +322,10 @@ class rectangle_topology : public convex_topology< 2 > rectangle_topology(double left, double top, double right, double bottom) : gen_ptr(new RandomNumberGenerator) , rand(new rand_t(*gen_ptr)) - , left(std::min BOOST_PREVENT_MACRO_SUBSTITUTION(left, right)) - , top(std::min BOOST_PREVENT_MACRO_SUBSTITUTION(top, bottom)) - , right(std::max BOOST_PREVENT_MACRO_SUBSTITUTION(left, right)) - , bottom(std::max BOOST_PREVENT_MACRO_SUBSTITUTION(top, bottom)) + , left((std::min)(left, right)) + , top((std::min)(top, bottom)) + , right((std::max)(left, right)) + , bottom((std::max)(top, bottom)) { } @@ -341,10 +333,10 @@ class rectangle_topology : public convex_topology< 2 > double right, double bottom) : gen_ptr() , rand(new rand_t(gen)) - , left(std::min BOOST_PREVENT_MACRO_SUBSTITUTION(left, right)) - , top(std::min BOOST_PREVENT_MACRO_SUBSTITUTION(top, bottom)) - , right(std::max BOOST_PREVENT_MACRO_SUBSTITUTION(left, right)) - , bottom(std::max BOOST_PREVENT_MACRO_SUBSTITUTION(top, bottom)) + , left((std::min)(left, right)) + , top((std::min)(top, bottom)) + , right((std::max)(left, right)) + , bottom((std::max)(top, bottom)) { } @@ -362,27 +354,21 @@ class rectangle_topology : public convex_topology< 2 > point_type bound(point_type a) const { - BOOST_USING_STD_MIN(); - BOOST_USING_STD_MAX(); point_type p; - p[0] = min BOOST_PREVENT_MACRO_SUBSTITUTION( - right, max BOOST_PREVENT_MACRO_SUBSTITUTION(left, a[0])); - p[1] = min BOOST_PREVENT_MACRO_SUBSTITUTION( - bottom, max BOOST_PREVENT_MACRO_SUBSTITUTION(top, a[1])); + p[0] = (std::min)(right, (std::max)(left, a[0])); + p[1] = (std::min)(bottom, (std::max)(top, a[1])); return p; } double distance_from_boundary(point_type a) const { - BOOST_USING_STD_MIN(); - BOOST_USING_STD_MAX(); #ifndef BOOST_NO_STDC_NAMESPACE using std::abs; #endif double dist = abs(left - a[0]); - dist = min BOOST_PREVENT_MACRO_SUBSTITUTION(dist, abs(right - a[0])); - dist = min BOOST_PREVENT_MACRO_SUBSTITUTION(dist, abs(top - a[1])); - dist = min BOOST_PREVENT_MACRO_SUBSTITUTION(dist, abs(bottom - a[1])); + dist = (std::min)(dist, abs(right - a[0])); + dist = (std::min)(dist, abs(top - a[1])); + dist = (std::min)(dist, abs(bottom - a[1])); return dist; } @@ -471,8 +457,6 @@ class ball_topology : public convex_topology< Dims > point_type bound(point_type a) const { - BOOST_USING_STD_MIN(); - BOOST_USING_STD_MAX(); double r = 0.; for (std::size_t i = 0; i < Dims; ++i) r = std::hypot(r, a[i]); From 99c6a3b0d50f41e53f700d321580509e7cf64556 Mon Sep 17 00:00:00 2001 From: andreacassioli Date: Tue, 27 Oct 2026 17:13:20 +0100 Subject: [PATCH 2/2] remove duplicated cmath include --- include/boost/graph/topology.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/boost/graph/topology.hpp b/include/boost/graph/topology.hpp index 251e380fc..4d05b3cb4 100644 --- a/include/boost/graph/topology.hpp +++ b/include/boost/graph/topology.hpp @@ -17,8 +17,6 @@ #include #include -#include - // Classes and concepts to represent points in a space, with distance and move // operations (used for Gurson-Atun layout), plus other things like bounding // boxes used for other layout algorithms.