Different visibility in template for class and struct?

Shigeki Karita shigekikarita at gmail.com
Mon May 11 15:11:17 UTC 2020


Why is local struct visible in this outer template, while local 
class is not?

https://wandbox.org/permlink/MfsDa68qgaMSIr4a

https://dlang.org/spec/template.html#instantiation_scope

---

enum p(T) = __traits(compiles, new T());

class GlobalC {}
struct GlobalS {}

void main()
{
     class LocalC {}
     static assert(p!GlobalC);
     static assert(!p!LocalC);

     struct LocalS {}
     static assert(p!GlobalS);
     static assert(p!LocalS); // ??
}



More information about the Digitalmars-d-learn mailing list