Boost logo

Boost :

From: Zara (yozara_at_[hidden])
Date: 2006-03-15 02:19:15


[This message has been crossposted to boost developers list, it has
been done on purpose, as it affects both communities]
[Sorry if it comes up twice on Boost]

I have detected that the standard declares "distance" template at
24.3.4, as taking two "InputIterator" as parameters.

IMHO, the parameters shoudl be "const InputIterator" as they should
not be changed by that function. In fact, the version I have seen of
STLPORT does implement it like that ("const InputIterator") violating
the standard, while DINKUMWARE respects the standard defintion.

This has given me some problems when trying to use BOOST libraries
with BDS 2006 (which comes with Dinkumware library).

The function "size" in boost::iterator_range is declared "const", so
that when it calls "std::distance", it will do so with "const
IteratorT" parameters. With STLPORT, there will be no problem, as the
undelying iterato_traits do not change.

But in the case of DINKUMWARE, the underlying iterator_traits change.
This is specially evident when IteratorT is [const] char *, which is a
valid random access iterator. "size" will call "std::distance" with
"[const] char * const" parameters, which are non-valid random
iterators.

I feel that DINKUMWARE is right in following the standard, but STLPORT
is right in following common sense. I suggest making both points of
view meet: a standard with common sense, that declares "distance" as
operating over "const InputIterator".

Best regards,

Zara


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