I wish all qualifiers were revisited with an eye for simplification
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Aug 17 11:23:04 UTC 2020
On 8/14/20 9:35 PM, Timon Gehr wrote:
> 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.
This is a problem as __traits should be a lower-level, seldom-used
resort. Are the distinctions between the two documented somewhere?
More information about the Digitalmars-d
mailing list