Orphan ranges
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Apr 16 21:07:34 PDT 2012
On 4/16/12 12:57 PM, Jonathan M Davis wrote:
> So, the problem that we have is basically
>
> void main()
> {
> Range r;
> {
> Container c = //allocated using allocator, however that works
> r = c[];
> }
> //Container may or may not exist in memory, depending on the allocator,
> //but the range does exist and may or may not be valid.
> }
Yes.
> How is this different from an iterator or range being invalidated after a
> function is called on the container which alters its state?
Well it's just a different matter. In particular containers offer the
unstable versions of their primitives when they mess iterators up.
> You could
> theoretically add plumbing to the range to keep track of whether it's valid or
> not, but we're not doing that or planning to do that with std.container are
> we?
I guess we have to, at least plant the decision to do so or not in the
allocator or in a policy.
Andrei
More information about the Digitalmars-d
mailing list