<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>Le 19 sept. 2011 à 09:25, Ruben Van Boxem a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><p>Op 19 sep. 2011 05:13 schreef "M.E. O&apos;Neill" <<a href="mailto:oneill@cs.hmc.edu">oneill@cs.hmc.edu</a>> het volgende:<br>
><br>
> Howard Hinnant wrote:<br>
> >>> There isn't a lot there yet.  I've tried to get vector working (just the primary, not vector<bool> so far), and I believe I have done so.  Though I don't have tests for it yet (I've just been spot checking).  At this point I'm simply exploring whether the basic design is viable or not.<br>

> >>><br>
> >>> A major goal of the design of this debug mode is to keep the ABI stable as debug mode is turned on/off.<br>
><br>
> Sounds good, but it'd be useful to have a more detailed design document somewhere so that people can see where you're going and how.<br>
><br>
> ... and Christopher Jefferson replied:<br>
> >> I have often seen interest on a "cheap" debugging mode, which would add checks which were possible without breaking complexity requirements, or "excessive" cost.<br>
><br>
> Without seeing Howard's design, I don't know how "excessive" the costs of his design might be, but in principle, you can do some checks like iterator invalidation very cheaply -- if you have the right design.<br>

><br>
> This may be obvious (in which case I apologize), it may even be what Howard has already done (in which case, oops, and, uh, cool), but in case it isn't, let me outline how:<br>
><br>
> - For every container, associate a 64-bit tag (a.k.a. version stamp).<br>
><br>
> - For every iterator, also associate a 64-bit tag.<br>
><br>
> - When you create a new container, just pick a random 64-bit value.<br>
><br>
> - When you create an iterator, copy the 64-bit tag from the associated container.  This represents the container/version the iterator belongs to.   Any access via the iterator checks that the tag of the iterator matches the tag of the container.  If it doesn't, BANG!<br>

><br>
> - When iterators are invalidated, generate a new tag for container. (For speed, you could just increment it, but the important point is that the value is a new and different one)<br>
><br>
> This method is probabilistic -- there is a 1 in 18446744073709551616 chance that it won't catch an invalid access, but personally I like those odds.  It also imposes very very little in runtime overhead -- you can invalidate N iterators in O(1) time.</p><p>Why not just use the cool c++11 random number generators, if performance would be an issue, time to optimise those ;-) I don't like the idea of probabilistic odds, especially in hugely iterated and containered program this would make debugging useless (especially for long-running server-like programs that would need to be debugged)</p></blockquote><div><br></div>if I correctly understand the issue, I would say this is because a random generator would not increase the number of possible values, and would instead increase the chance of collision.</div><div><br></div><div>With 64 bit counter, even if you increase it 1 billion times per second, you need more than 500 years to overflow.<br></div><div><br></div><div>
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div>-- Jean-Daniel</div><div><br></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br></body></html>