I wish all qualifiers were revisited with an eye for simplification

Timon Gehr timon.gehr at gmx.ch
Sat Aug 15 01:35:32 UTC 2020

On 15.08.20 03:29, Timon Gehr wrote:
>> Simple questions should have simple answers.
> If the above implementation of isCopyable is not the one you want, 
> something else is off.

Oh, actually I misspoke, didn't notice that you changed my suggestion 
from the github issue from __traits(compiles, ...) to is(typeof(...)).

Use __traits(compiles, ...), not is(typeof(...)). typeof assigns types 
to expressions that would not otherwise compile, even lambdas:

void main(){
     int x;
     static void foo(){
         pragma(msg, typeof(()=>x));             // int delegate() pure 
nothrow @nogc @safe
         pragma(msg, __traits(compiles, ()=>x)); // false

There is this persistent myth that __traits(compiles, ...) is the same 
as is(typeof(...)) this is not the case and IIRC I have used it to 
demonstrate that most template constraints in Phobos don't work correctly.

More information about the Digitalmars-d mailing list