@nogc and Exceptions
IGotD-
nise at nise.com
Thu Sep 29 12:53:30 UTC 2022
On Thursday, 29 September 2022 at 12:12:34 UTC, Quirin Schroll
wrote:
>
> Some explanation for why it is like this:
> * One has to use `alias doAllocate = function E(Args args) =>
> new E(args);` instead of a normal function definition because a
> normal function definition does not infer attributes.
> `throw_new` has attributes inferred.
> * `isSafe` and `isPure` take care that those attributes are
> carried through if `E`’s constructor happens to have them.
> * `hackedAllocate` is created via a `@trusted` block because
> adding `@nogc` is not `@safe`. It only trusts the cast, not the
> call.
> * Perfect forwarding for the arguments is not trivial (I
> tried), but probably not needed anyway.
Deallocation is just as interesting for completeness in this
example which was left out for some reason.
More information about the Digitalmars-d
mailing list