From 2c3ee866b614d3c0695ae5de5931c366466b559f Mon Sep 17 00:00:00 2001 From: Christopher Kormanyos Date: Thu, 18 Apr 2024 10:21:09 +0200 Subject: [PATCH] Portable minmax Win32-API workaround #744 (#745) Co-authored-by: Christopher Kormanyos --- include/boost/gil/extension/histogram/std.hpp | 4 ++-- include/boost/gil/extension/io/tiff/detail/read.hpp | 6 +++--- include/boost/gil/histogram.hpp | 12 ++++++------ .../gil/image_processing/histogram_equalization.hpp | 8 ++++---- .../gil/image_processing/histogram_matching.hpp | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/include/boost/gil/extension/histogram/std.hpp b/include/boost/gil/extension/histogram/std.hpp index a015078212..67e9a66f65 100644 --- a/include/boost/gil/extension/histogram/std.hpp +++ b/include/boost/gil/extension/histogram/std.hpp @@ -59,7 +59,7 @@ void fill_histogram(SrcView const& srcview, std::vector& histogram, bool accu if (!accumulate) histogram.clear(); - histogram.resize(std::numeric_limits::max() + 1); + histogram.resize((std::numeric_limits::max)() + 1); for_each_pixel(color_converted_view(srcview), [&](pixel_t const& p) { ++histogram[static_cast(p)]; @@ -81,7 +81,7 @@ void fill_histogram(SrcView const& srcview, std::array& histogram, bool ac using channel_t = typename channel_type::type; using pixel_t = pixel; - const size_t pixel_max = std::numeric_limits::max(); + const size_t pixel_max = (std::numeric_limits::max)(); const float scale = (histogram.size() - 1.0f) / pixel_max; if (!accumulate) diff --git a/include/boost/gil/extension/io/tiff/detail/read.hpp b/include/boost/gil/extension/io/tiff/detail/read.hpp index e0f40f412c..13ce23d618 100644 --- a/include/boost/gil/extension/io/tiff/detail/read.hpp +++ b/include/boost/gil/extension/io/tiff/detail/read.hpp @@ -663,9 +663,9 @@ class reader< Device std::size_t element_size = sizeof( Pixel ); - std::size_t ret = std::max( width - , (( scanline_size_in_bytes + element_size - 1 ) / element_size ) - ); + std::size_t ret = (std::max)( width + , (( scanline_size_in_bytes + element_size - 1 ) / element_size ) + ); return ret; } diff --git a/include/boost/gil/histogram.hpp b/include/boost/gil/histogram.hpp index 9bf66ab90b..9012089541 100644 --- a/include/boost/gil/histogram.hpp +++ b/include/boost/gil/histogram.hpp @@ -136,11 +136,11 @@ bool tuple_compare(Tuple const& t1, Tuple const& t2) template struct tuple_limit { - static constexpr Tuple min() + static constexpr Tuple (min)() { return min_impl(boost::mp11::make_index_sequence::value>{}); } - static constexpr Tuple max() + static constexpr Tuple (max)() { return max_impl(boost::mp11::make_index_sequence::value>{}); } @@ -150,14 +150,14 @@ struct tuple_limit static constexpr Tuple min_impl(boost::mp11::index_sequence) { return std::make_tuple( - std::numeric_limits::type>::min()...); + (std::numeric_limits::type>::min)()...); } template static constexpr Tuple max_impl(boost::mp11::index_sequence) { return std::make_tuple( - std::numeric_limits::type>::max()...); + (std::numeric_limits::type>::max)()...); } }; @@ -638,9 +638,9 @@ void fill_histogram( bool applymask = false, std::vector> mask = {}, typename histogram::key_type lower = - detail::tuple_limit::key_type>::min(), + (detail::tuple_limit::key_type>::min)(), typename histogram::key_type upper = - detail::tuple_limit::key_type>::max(), + (detail::tuple_limit::key_type>::max)(), bool setlimits = false) { if (!accumulate) diff --git a/include/boost/gil/image_processing/histogram_equalization.hpp b/include/boost/gil/image_processing/histogram_equalization.hpp index 6ce3c5ef34..fba98f87ce 100644 --- a/include/boost/gil/image_processing/histogram_equalization.hpp +++ b/include/boost/gil/image_processing/histogram_equalization.hpp @@ -70,8 +70,8 @@ auto histogram_equalization(histogram const& src_hist, histogram::value_type; dst_hist.clear(); double sum = src_hist.sum(); - SrcKeyType min_key = std::numeric_limits::min(); - SrcKeyType max_key = std::numeric_limits::max(); + SrcKeyType min_key = (std::numeric_limits::min)(); + SrcKeyType max_key = (std::numeric_limits::max)(); auto cumltv_srchist = cumulative_histogram(src_hist); std::map color_map; std::for_each(cumltv_srchist.begin(), cumltv_srchist.end(), [&](value_t const& v) { @@ -120,8 +120,8 @@ void histogram_equalization( std::size_t const channels = num_channels::value; coord_t const width = src_view.width(); coord_t const height = src_view.height(); - std::size_t pixel_max = std::numeric_limits::max(); - std::size_t pixel_min = std::numeric_limits::min(); + std::size_t pixel_max = (std::numeric_limits::max)(); + std::size_t pixel_min = (std::numeric_limits::min)(); for (std::size_t i = 0; i < channels; i++) { diff --git a/include/boost/gil/image_processing/histogram_matching.hpp b/include/boost/gil/image_processing/histogram_matching.hpp index 25107a7de6..1b947c426f 100644 --- a/include/boost/gil/image_processing/histogram_matching.hpp +++ b/include/boost/gil/image_processing/histogram_matching.hpp @@ -166,10 +166,10 @@ void histogram_matching( std::size_t const channels = num_channels::value; coord_t const width = src_view.width(); coord_t const height = src_view.height(); - source_channel_t src_pixel_min = std::numeric_limits::min(); - source_channel_t src_pixel_max = std::numeric_limits::max(); - ref_channel_t ref_pixel_min = std::numeric_limits::min(); - ref_channel_t ref_pixel_max = std::numeric_limits::max(); + source_channel_t src_pixel_min = (std::numeric_limits::min)(); + source_channel_t src_pixel_max = (std::numeric_limits::max)(); + ref_channel_t ref_pixel_min = (std::numeric_limits::min)(); + ref_channel_t ref_pixel_max = (std::numeric_limits::max)(); for (std::size_t i = 0; i < channels; i++) {