<div dir="ltr">To clarify, I'm only asking about a struct allocated via new.<div>Unique!T is wrapped around a struct, but it allocates a struct T via 'new', so my question still holds: does 'delete t' (where t is a struct allocated via new) guarantee deterministic destruction?</div><div><br></div><div>I'm guessing yes, otherwise Unique would be broken, but where is that specified in the docs?</div><div>And if delete is to be deprecated (according to the docs), what is the correct way to do that (despite fact that Unique relies on delete).</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 7, 2015 at 4:02 PM, weaselcat via Digitalmars-d-learn <span dir="ltr"><<a href="mailto:digitalmars-d-learn@puremagic.com" target="_blank">digitalmars-d-learn@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Saturday, 7 March 2015 at 23:48:39 UTC, Timothee Cour wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm a little confused about the following:<br>
clear,delete,destroy.<br>
My understanding is that clear is deprecated and delete is planned to be<br>
deprecated, so we should only ever use destroy (which deterministic calls<br>
the destructor but doesn't release memory).<br>
<br>
Unique uses delete however in the destructor. Is that still guaranteeing<br>
deterministic destruction when the uniqued element is either a class or<br>
struct? (ie if the destructor has a file handle resource, will it be<br>
deterministically freed?)<br>
</blockquote>
<br></div></div>
structs are allocated on the stack(unless instantiated with new), and call their destructor when you leave their scope. Unique still guarantees deterministic destruction because it's wrapped around a struct, it's a fairly common 'D idiom' I'd say(i.e, look at how File is implemented - D's runtime and standard library are surprisingly well documented and easy to read.)<br>
<br>
I'm not sure why Unique uses delete, might just be bitrot.<br>
</blockquote></div><br></div>