Boost logo

Boost :

Subject: Re: [boost] counting_iterator<int>::difference_type
From: Kim Kuen Tang (kuentang_at_[hidden])
Date: 2010-04-13 05:32:36


Arno Schödl schrieb:
> Hello,
>
>
>
> I am sure this has come up a few times, but I could not find the answer in the archive.
>
>
>
> counting_iterator<int>::difference_type is __int64 by default. I understand the underlying rationale, but I am not sure whether it is the right choice given the existing practice of C/C++. The problem of int minus int overflowing is not restricted to counting_iterator. Still, C/C++ chose to make int minus int -> int, probably for performance reasons. So why shouldn't counting_iterator by default behave the same way? If someone needs something else, she can still override the default.
>
>
You are able to override the difference_type by providing your own type.
See:
boost::counting_iterator<int,boost::use_default,int>::difference_type

HTH

Kim
>
> Arno
>
>
> --
> Dr. Arno Schoedl · aschoedl_at_[hidden]
> Technical Director
>
> think-cell Software GmbH · Chausseestr. 8/E · 10115 Berlin, Germany
> http://www.think-cell.com · phone +49 30 666473-10 · toll-free (US) +1 800 891 8091
> Directors: Dr. Markus Hannebauer, Dr. Arno Schoedl · Amtsgericht Berlin-Charlottenburg, HRB 85229
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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