|
Boost : |
From: Darin Adler (darin_at_[hidden])
Date: 2002-08-01 21:25:03
On Thursday, August 1, 2002, at 05:18 PM, Beman Dawes wrote:
> At 08:04 PM 8/1/2002, Glen Knowles wrote:
>> I believe begin() should return a const iterator, you then assign it
>> to a 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.
Not true. You can copy a const object into non-const variable. Consider
a function that returns const int. There's no problem assigning that to
an int variable.
You'd only have to cast away const if you were changing the type of the
object itself rather than copying its value.
> Furthermore, the Standard Library container requirements, table 65,
> require that the return type of begin() be "iterator", not "const
> iterator".
Definitely correct.
> Again, I don't think the Filesystem Library is the place to try to
> solve wider iterator problems.
I don't think this is really about wider iterator problems. The
argument you cite for making return values of type string be const
string does apply equally well to the iterators, in my opinion. But as
you say, this would be incompatible with the standard library container
requirements.
-- Darin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk