[cfe-dev] [libc++] debug mode

M.E. O'Neill oneill at cs.hmc.edu
Mon Sep 19 14:40:23 PDT 2011


I wrote:
>> There are details, of course, such as reference counting things so that it all cleans up nicely (i.e., you only keep as much of the invalidation log as you actually need), and handling tag collisions for record information (because you really shouldn't *ever* fail for valid code, even if it is more likely that the user will be struck by lightning while in the bathroom).  But I think those details are pretty straightforward.

and Steven Watanabe replied:
> [ideas deleted]

I was certainly thinking more along the lines of your second idea.  The reference count is the number of direct references, either from iterators directly using that tag, or the reference from the tag's predecessor in history. (*)

> A single long-lived iterator can cause the history to accumulate indefinitely.

Yes, this is true.  But in practice it only happens if you keep doing lots of erases and you have one long-lived iterator you never actually use.  Any actual full invalidation breaks the chain.  Likewise actually using the iterator will update it.   I suspect it would be more of a problem in theory than practice.

Feel free to suggest alternative designs or variations; my preference though is for schemes where mass iterator invalidation is O(1) (and actually fairly cheap), and the common case (valid iterators) is fast.

    M.E.O.





More information about the cfe-dev mailing list