typeof on protected field

bauss jj_1337 at live.dk
Sat Jun 16 13:12:13 UTC 2018


On Saturday, 16 June 2018 at 08:32:38 UTC, DigitalDesigns wrote:
> mixin(`foo!(typeof(T.`~m~`));
>
> gives me an error about m being protected.
>
> Error: class `X` member `name` is not accessible.
>
> this also happens when using __traits(getMember, T, m); X is in 
> another module. Works fine when X is in the same module.
>
> I need to get the protected and private members for 
> serialization.

You can't get that information when they're in another module, 
unfortunately.

The only solution would be to expose them as public or have a 
public member expose them.


More information about the Digitalmars-d-learn mailing list