Boost logo

Boost :

From: Glen Knowles (gknowles_at_[hidden])
Date: 2002-08-01 21:44:33

> > I believe begin() should return a const iterator, you then assign it to
> > non-const iterator ("it" above) and then inc/dec the copy.
> I doubt users would find that attractive. You would have to cast away
> const.

How so? We're making a copy, not modifying the original. As in (tested):

const vector<int>::iterator iter(vector<int>& vec) { return vec.begin(); }

int main() {
  vector<int> vec;
  vector<int>::iterator iv = iter(vec);

> Furthermore, the Standard Library container requirements, table 65,
> that the return type of begin() be "iterator", not "const iterator".

That may be a good enough argument, although I don't see any advantages to
"iterator" over "const iterator".


Boost list run by bdawes at, gregod at, cpdaniel at, john at