Boost logo

Boost :

From: Kevin Sopp (baraclese_at_[hidden])
Date: 2007-10-18 16:47:04


> const_iterator it = const_splay_tree.find(a); //Splaying performed
>
> would break usual de-facto thread-safety guarantees for STL and
> Intrusive containers (read-only access from different threads is
> thread-safe).

In other words, this is dangerous and misleading.

> So the main question is: what approach do you think would be better?
> ¿Just splay in const operations and put a thread-safety warning? ¿Make
> const versions non-splaying? ¿Don't offer const versions of search
> functions?

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.

Kevin


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