Different visibility in template for class and struct?
Steven Schveighoffer
schveiguy at gmail.com
Mon May 11 16:10:36 UTC 2020
On 5/11/20 11:40 AM, Shigeki Karita wrote:
> On Monday, 11 May 2020 at 15:29:53 UTC, Steven Schveighoffer wrote:
>> On 5/11/20 11:11 AM, Shigeki Karita wrote:
>>> [...]
>>
>> First, it actually does compile, I think because the compiler
>> recognizes that LocalS is POD (plain old data), without methods, so it
>> doesn't need a context pointer.
>>
>> e.g.:
>>
>> auto make(T)() { return new T(); }
>>
>> ...
>>
>> auto x = make!LocalS; // ok
>>
>> If you add a method to LocalS, then make!LocalS fails to compile.
>> However, strangely, p!LocalS still returns true, I think that is an
>> error.
>>
>
> Thanks for your answer. Now I understand that POD matters here.
>
> When I add a dtor: `struct LocalS { ~this() {} }`, the `p!LocalS` got
> false.
There is still a bug though. if p!T returns true, but make!T doesn't
compile, then something is inconsistent.
-Steve
More information about the Digitalmars-d-learn
mailing list