|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-12-10 07:51:11
goochrules! wrote:
>> I know this is not the correct place to suggest new features to the STL,
>> but I can't find a similar group for STL. Any suggestions?
>>
>> Sorry for the interruption.
>>
>> P.S. In case you're wondering what the suggestion is: Add ability to use
>> random access operators with iterators. E.g.
>>
>> vector<int> intv;
>> ...
>> vector<int>::iterator i=intv.begin();
>> intv[i]++;
>
> What do you want that last line to do? To me it looks like you could
> be using "(*i)++;" instead to achieve the same result.
>
>> It seems odd and confusing that iterators have pointer semantics but not
>> random access semantics.
>
> they do already, well, some of them at least do (of which, vector is
> one): http://www.sgi.com/tech/stl/RandomAccessIterator.html.
Random access iterators do have random access semantics, but that
particular expression won't compile with some (mutable) random access
iterators. The problem is that the result of p[i] is only required to
be convertible to the iterator's value_type.
Cheers,
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net