Boost logo

Boost :

Subject: Re: [boost] [histogram] should some_axis::size() return unsigned or int?
From: Hans Dembinski (hans.dembinski_at_[hidden])
Date: 2018-12-04 13:33:02


> On 4. Dec 2018, at 04:27, Brook Milligan <brook_at_[hidden]> wrote:
>
>
>> On Dec 3, 2018, at 10:08 PM, Hans Dembinski <hans.dembinski_at_[hidden]> wrote:
>>
>> I am aware of the Boost operators library, but it is good that you remind me. If I allow my size_type to be implicitly convertible to int, I do not even have so many operators to implement. Implicit conversions are often bad, but it may be ok here.
>
> Is this discussion moving in the direction of a safe_unsigned<T> type, i.e., unsigned without modulo arithmetic? I can't recall if Robert Ramey's safe_numerics library does that, but that might be useful.

I was wondering about the same thing. I only had a quick look into it, but it could potentially be very useful.

I tried to implement such a safe_unsigned type yesterday evening, but eventually gave up. This is really a lot of added complexity just to avoid a warning that users may not even see, if they compile without warnings enabled. Perhaps I can use the safe_numerics library in a future version of boost.histogram to better solve this issue, but for now I will let axis::size() return `int`.


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