On Thursday, 11 September 2025 at 11:47:40 UTC, Dennis wrote:
On Wednesday, 10 September 2025 at 12:29:24 UTC, IchorDev wrote:
If anyone has any ideas, please let me know.

The trick that's used in druntime is putting the part that still needs to be checked for attributes inside an `if (false)` block, for example:

https://github.com/dlang/dmd/blob/c81714b9bc7626e1d235fb2d6279dc73d47c9174/druntime/src/core/lifetime.d#L1981

You can also use `static if` and a no-op `@system` function:

```d
@system pure nothrow @nogc
pragma(inline, true)
void inferSystem() {}

T* example(T)()
{
    import std.traits: isSafe;

    static if (!isSafe!(() { new T(); })
        inferSystem();

    void[] memory = new void[](T.sizeof);
    return (() @trusted => new (memory) T())();
}
```
  • Placement new an... IchorDev via Digitalmars-d-learn
    • Re: Placeme... Dennis via Digitalmars-d-learn
      • Re: Pla... Paul Backus via Digitalmars-d-learn
        • Re:... IchorDev via Digitalmars-d-learn
    • Re: Placeme... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
      • Re: Pla... IchorDev via Digitalmars-d-learn
        • Re:... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
          • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
            • ... IchorDev via Digitalmars-d-learn
              • ... Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
                • ... IchorDev via Digitalmars-d-learn
          • ... Paul Backus via Digitalmars-d-learn
            • ... IchorDev via Digitalmars-d-learn

Reply via email to