Boost logo

Boost :

From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2007-10-19 18:03:15

Michael Fawcett escribió:
> On 10/18/07, Kevin Sopp <baraclese_at_[hidden]> wrote:
>> Making the const versions non-splaying would destroy the functional
>> equivalence between const and non-const search functions which might
>> come as a surprise for programmers that did not read the documentation
>> well. So i would opt for "don't offer const versions of search
>> functions".
>> IMO using
>> iterator it = splay_tree.find(a, dont_splay);//No splay
>> is superior.
> How about reversing that? Offer the const find as a non-splaying
> operation, and offer a non-const find overload that explicitly asks
> for splaying?
> iterator it = splay_tree.find(a);//No splay
> iterator it = splay_tree.find(a, splay);//Splay operation performed
> or maybe spell out all splaying functions as *_and_splay (e.g. find_and_splay).

Thanks for your comments. Both options seems reasonable. I think the
user of a splay_tree expects splaying as the default option, so I'm
starting to think that avoiding const versions could be a better choice
(generic code using non-const containers would work). Users that are
sure about thread-safety can uncast the container before passing it to
the algorithm. Anyway, I'm afraid my opinion might change again ;-)



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