Boost logo

Boost :

From: Beman Dawes (bdawes_at_[hidden])
Date: 2002-08-01 16:58:09


At 12:00 PM 8/1/2002, Mattias Flodin wrote:

>On Thu, Aug 01, 2002 at 08:33:24AM -0400, Beman Dawes wrote:
>> >What I've been meaning to ask, after this somewhat wordy post, are two
>> >things. First, path::begin() returns a mutable iterator. Shouldn't it
be
>> >returning a const iterator, for the same reasons as above? Same thing
>> >goes for path::end().
>>
>> I'm not quite sure what you mean here.
>
>I mean that code such as
>
>path p2("foo/bar");
>p2.begin() = p2.end();
>path::iterator it = ++p2.begin();
>
>is legal.

Ah, yes, I see what you mean. But that is a general problem with the
design of iterators, isn't it, rather than a problem with
path? path::begin() can't return a const iterator; iteration (operator++,
operator--) wouldn't work!

> In other words the return value from path::begin() is mutable
>and the one returned from path::leaf() is not. This is inconsistent. Or
>am I mistaken?

leaf() has the same semantics as the standard's optional sequence operation
back(), although it returns by value rather than reference. That design
decision reflects my opinion that a path shouldn't be viewed as a
full-blown container, but rather a specialized component which happens to
have a few characteristics in common with containers.

>Speaking of the docs, a description of what many of the functions
>(e.g. path::leaf()) do seems to be missing. But perhaps that's on the
>todo list.

Are you looking at the latest version? Or perhaps it is confusing that
path::leaf() and a number of other functions are fully specified simply by
their "Returns" paragraph? But that's all there is to it; you don't need
an involved description.

Thanks for the comments!

I'd also like to hear usage reports, if anyone is trying the library out on
real work.

--Beman


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