Re: [Template] Mixins and foreach

2017-10-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 06:32:53 Nicholas Wilson via Digitalmars-d-learn wrote: > On Sunday, 1 October 2017 at 06:27:21 UTC, Nicholas Wilson wrote: > > And am getting > > util.d(72,12): Error: template instance helper!(foo) cannot use > > local 'foo' as parameter to non-global template > > hel

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 06:27:21 UTC, Nicholas Wilson wrote: And am getting util.d(72,12): Error: template instance helper!(foo) cannot use local 'foo' as parameter to non-global template helper(Fields...) Fixed by making helper a global template. Thanks Jonathan!

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 04:44:16 UTC, Jonathan M Davis wrote: I don't see any reason why the compiler would be complaining about 'this' being required. Neither do I. I would think that that would imply that the compiler thinks that you're accessing the member rather than introspecting on

Re: [Template] Mixins and foreach

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 03:11:15 Nicholas Wilson via Digitalmars-d-learn wrote: > On Sunday, 1 October 2017 at 02:29:57 UTC, Jonathan M Davis wrote: > > I would have thought that it would be pretty straightforward to > > just write a recursive, eponymous template to solve the problem > > and h

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 02:29:57 UTC, Jonathan M Davis wrote: I would have thought that it would be pretty straightforward to just write a recursive, eponymous template to solve the problem and have it recursively build a single string to mix in for everything. In general though, without

Re: [Template] Mixins and foreach

2017-09-30 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, October 01, 2017 02:07:26 Nicholas Wilson via Digitalmars-d-learn wrote: > On Sunday, 1 October 2017 at 01:05:56 UTC, Nicholas Wilson wrote: > > struct MyType > > { > > > > void* raw; > > static struct Info > > { > > > > @(42) int foo; > > > > } > > mixin gen

Re: [Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 1 October 2017 at 01:05:56 UTC, Nicholas Wilson wrote: struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias

[Template] Mixins and foreach

2017-09-30 Thread Nicholas Wilson via Digitalmars-d-learn
struct MyType { void* raw; static struct Info { @(42) int foo; } mixin generateGetInfo!MyTypeGetInfo; } extern(C) void MyTypeGetInfo(void*,int,size_t,void*size_t*); mixin template generateGetInfo(alias func) { foreach(field; typeof(this).Info.tupleof) {