January 07, 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)));
}
January 07, 2013
On Monday, 7 January 2013 at 15:37:48 UTC, Tove wrote:
> 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)));
> }

»private« means »accessible from this module« – are you running your tests with my_struct defined in a different module?

David
1 2
Next ›   Last »