Need for std.meta.isSame over __traits(isSame)

Per Nordlöw per.nordlow at gmail.com
Wed Sep 1 22:51:40 UTC 2021


Can somebody explain the need for

```d
private template isSame(alias a, alias b)
{
     static if (!is(typeof(&a && &b)) // at least one is an rvalue
             && __traits(compiles, { enum isSame = a == b; })) // 
c-t comparable
     {
         enum isSame = a == b;
     }
     else
     {
         enum isSame = __traits(isSame, a, b);
     }
}
```

when there is already

```d
__traits(isSame, a, b)
```

?

Are there any cases where

```d
__traits(isSame, a, b)
```

doesn't have the same value as

```d
a == b
```

provided the static if expression above is true.


More information about the Digitalmars-d-learn mailing list