Subject: Re: [boost] [histogram] should some_axis::size() return unsigned or int?
From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2018-11-30 00:10:37
On Thu, Nov 29, 2018 at 3:38 PM Gavin Lambert via Boost <
> On 30/11/2018 06:12, Hans Dembinski wrote:
> > This is not a good match here, because -1 here does not have the
meaning of "value is missing", but it really is the logical index for the
virtual bin that spans from -infinity to the lower edge of the first bin in
> > Value arrow:
> > -inf âââââââ | âââââââ | ââââââ | ââââââ |âââââââââ> +inf
> > bin -1 bin 0 bin 1 bin 2 bin 3
> > I think representing the underflow bin with -1 and the overflow bin
with the value returned by size() is very intuitive and elegant.
> Conventionally your size_type should be the same type returned by size()
> and used for indexing. So I would expect that type to be int, given the
> Having said that, you're already departing from standard container
> conventions by having size() return a number that is *sometimes* 2
> smaller than the "real" number of bins, which might frustrate generic
> Completely without tongue in cheek, I wonder if it might be better to
> not provide a size() method at all (to avoid container implications
> which you do not satisfy) and spell it as bin_count() or something
> distinct instead.
If the operation differs semantically from .size() in standard containers,
then it shouldn't be called size().
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk