Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 17:57:49 UTC, Johannes Pfau wrote: Am Fri, 14 Apr 2017 13:41:45 + schrieb Moritz Maxeiner : [...] Great, thanks that's exactly the solution I wanted. Figuring this out by myself is a bit above my template skill level ;-) -- Johannes

Re: Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
Am Fri, 14 Apr 2017 13:41:45 + schrieb Moritz Maxeiner : > On Friday, 14 April 2017 at 11:29:03 UTC, Johannes Pfau wrote: > > > > Is there some way to wrap the 'type selection'? In pseudo-code > > something like this: > > > > enum FilteredOverloads(API) = ... > > > >

Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 11:29:03 UTC, Johannes Pfau wrote: Is there some way to wrap the 'type selection'? In pseudo-code something like this: enum FilteredOverloads(API) = ... foreach(Overload, FilteredOverloads!API) { } Sure, but that's a bit more complex: --- [...] //

Re: Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
Am Fri, 14 Apr 2017 08:55:48 + schrieb Moritz Maxeiner : > > mixin Foo!(API, (MethodType) { > // function dependent code here > }); > foo(); > --- > > Option 2: Code generation using CTFE > > --- > string genFoo(alias API, string justDoIt) > { > import std.array :

Re: Deduplicating template reflection code

2017-04-14 Thread Moritz Maxeiner via Digitalmars-d-learn
On Friday, 14 April 2017 at 08:24:00 UTC, Johannes Pfau wrote: I've got this code duplicated in quite some functions: - [...]1 foreach (MethodType; overloads) { // function dependent code here } [...]2

Re: Deduplicating template reflection code

2017-04-14 Thread Stefan Koch via Digitalmars-d-learn
On Friday, 14 April 2017 at 08:24:00 UTC, Johannes Pfau wrote: I've got this code duplicated in quite some functions: - foreach (member; __traits(derivedMembers, API)) { // Guards against private members static if (__traits(compiles, __traits(getMember, API,

Deduplicating template reflection code

2017-04-14 Thread Johannes Pfau via Digitalmars-d-learn
I've got this code duplicated in quite some functions: - foreach (member; __traits(derivedMembers, API)) { // Guards against private members static if (__traits(compiles, __traits(getMember, API, member))) { static if (isSomeFunction!(__traits(getMember,