Boost logo

Boost :

From: Neil Groves (neilgroves_at_[hidden])
Date: 2020-01-10 12:05:21


On Thu, 9 Jan 2020 at 21:45, Wim Leflere via Boost <boost_at_[hidden]>
wrote:

> Hello,
>
> I was wondering why the (i)range function is limited to integers.
>
> https://www.boost.org/doc/libs/1_72_0/libs/range/doc/html/range/reference/ranges/irange.html
>
>
> It would be nice if it also supported floats.
> Or any 'incrementable' class, e.g. Date.
>
>
Support for floating point was consciously not included since it would be
highly likely to cause problems. The inequality of a float range would
almost certainly require a predicate to consider the appropriate epsilon.
We could have coped with the precondition constraints for rejecting NaN but
the inequality predicate problem means a different interface. I therefore
concluded it was not a priority. I am of the current opinion that it is of
very little value, and potentially negative utility to provide this in
Boost.Range.

For Date since Boost.DateTime provides the TimeIterator one can create a
range. There is a general idioms for creating ranges from iterators see
make_iterator_range, iterator_range, sub_range etc. Hence the specific name
is not provided since it is not required.

The reason I did not generally support making a range from an Incrementable
is because Incrementable is necessary but not sufficient.

> Regards,
> Wim Leflere
>
>
HTH,
Neil Groves


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