Instantiation of nested structs should be allowed outside their parent scope

Timon Gehr timon.gehr at gmx.ch
Tue Nov 9 09:24:29 UTC 2021


On 08.11.21 02:02, Stanislav Blinov wrote:
> 
> If you're not convinced, I encourage you to try and define e.g.
> 
> ```d
> enum bool isNothrowCopyable(To, From) = /* ??? */
> ```


There is never really a need to instantiate a value of any type just to 
check what it supports. Just use parameters in your function literal. 
This has the side effect of supporting `inout` shenanigans as well.

enum bool isNothrowCopyable(To, From) = __traits(compiles, (To to, From 
from)nothrow{ to=from; });

(Untested. If I have misunderstood what it should check for, just change 
the function body.)


More information about the Digitalmars-d mailing list