Boost logo

Boost :

Subject: Re: [boost] please integrate patches for Boost.Gil and Boost.Graph
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2018-04-09 18:34:06


On 04/09/18 18:07, Brook Milligan via Boost wrote:
> I am not sure what the correct procedure for this is, but there are at least two old patches that would improve Boost.Gil and Boost.Graph. I would greatly appreciate it if someone integrates these. I have been using these for some time now with no detrimental effects.
>
> The patch to Boost.Gil corrects clearly incorrect code.
>
> The patch to Boost.Graph solves a problem that should never have been in the original design in the first place. Since it expands the acceptable set of arguments to cover the full range of values any user would expect and has the original semantics for cases that worked before, as far as I can see there can be no effect on existing user code.
>
> Thank you very much.
>
> Cheers,
> Brook
>
>
>
> See the following:
>
> - https://lists.boost.org/Archives/boost/2013/02/200721.php
> - https://svn.boost.org/trac10/ticket/7270
> - https://svn.boost.org/trac10/ticket/9517
> - https://svn.boost.org/trac10/attachment/ticket/9517/gil_channel_algorithm.patch
> - https://svn.boost.org/trac10/ticket/13397
>
> --- boost/gil/channel_algorithm.hpp.orig 2018-02-23 22:45:42.000000000 -0700
> +++ boost/gil/channel_algorithm.hpp 2018-03-11 22:05:31.000000000 -0600
> @@ -25,6 +25,7 @@
>
> #include "gil_config.hpp"
> #include "channel.hpp"
> +#include <limits>
> #include <boost/mpl/less.hpp>
> #include <boost/mpl/integral_c.hpp>
> #include <boost/mpl/greater.hpp>
> @@ -51,7 +52,7 @@
>
>
> template <typename UnsignedIntegralChannel>
> -struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};
> +struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,std::numeric_limits<UnsignedIntegralChannel>::max()> {};

This requires `std::numeric_limits<UnsignedIntegralChannel>::max()` to
be constexpr, i.e. a C++11 compiler. It has to be done differently for
compatibility with C++03, for example:

 
static_cast<UnsignedIntegralChannel>(~static_cast<UnsignedIntegralChannel>(0u))

The original code is also correct, although it might generate some
warnings, which could be resolved with a cast:

   static_cast<UnsignedIntegralChannel>(-1)


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk