Accessing UDA of private field
Tove
tove at fransson.se
Mon Jan 7 07:37:47 PST 2013
On Monday, 7 January 2013 at 13:36:47 UTC, Jacob Carlborg wrote:
> On 2013-01-07 12:59, Tove wrote:
>
>> in which context does private fail? I'm using something like
>> this:
>>
>> struct my_struct
>> {
>> private:
>> @(1) int t1;
>> @(2) int t2;
>> @(3) int t3;
>> }
>>
>> foreach(m; __traits(allMembers, my_struct))
>> with(my_struct.init)
>> pragma(msg, __traits(getAttributes, mixin(m)));
>
> Using a mixin works.
but this seems to work too?
import std.traits;
struct my_struct
{
private:
@(1) int t1;
@(2) int t2;
@(3) int t3;
}
void main()
{
foreach(m; __traits(allMembers, my_struct))
pragma(msg, __traits(getAttributes, __traits(getMember,
my_struct, m)));
}
More information about the Digitalmars-d
mailing list