Mitigating the attribute proliferation - attribute inference for functions
Kagamin via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 18 03:33:28 PDT 2015
On Friday, 17 July 2015 at 12:43:33 UTC, Martin Nowak wrote:
> This is how move would look like to support @safe inference.
>
> void move(T)(ref T source, ref T target)
> {
> if (() @trusted { return &source == ⌖ }())
> return;
> // Most complicated case. Destroy whatever target had
> in it
> // and bitblast source over it
> static if (hasElaborateDestructor!T) () @trusted {
> typeid(T).destroy(&target); }();
>
> static if (hasElaborateAssign!T || !isAssignable!T)
> () @trusted { memcpy(&target, &source, T.sizeof);
> }();
This looks complicated by safety, while other attributes are
inferred transparently.
More information about the Digitalmars-d
mailing list