|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2004-03-16 17:24:29
> reverse is not a member function of indexed_set, but rather of
> sequenced indices. The line:
>
> tc.reverse();
>
> works because the indexed_set inherits the public interface of
> its first index. So this is but an abbreviation of:
>
> tc.get<0>().reverse();
>
> (This particular point of indexed_set inheriting index #0 interface
> has originated some perplexities in other readers.)
That is clever, but the potential for confusion far outweighs any benefit
(IMHO). Do you have any strong supporters for the idea?
> Now, reverse is a memfun of sequenced indices for the simple
> reason that it is also present in std::list (and sequenced indices
> mimic its interface as closely as possible.) As std::sets do not
> have a reverse operation, neither do regular indices (furthermore,
> this op does not make sense for such indices.)
I think the function makes sense: I can call reverse on the index then call
some complex function that uses begin/end, to save having to write a
rbegin/rend version. E.g. to process a list from oldest to youngest instead
of youngest to oldest.
I also think the interface for regular and sequenced indices should be as
close as possible, as I'm sure I'm going to want to write generic functions
that take either type.
Darren
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk