Re: Store struct tuple of alias and access members through it?

2018-04-19 Thread Timoses via Digitalmars-d-learn
On Saturday, 7 April 2018 at 19:21:30 UTC, Simen Kjærås wrote: import std.meta; import std.traits; // List all member functions, and wrap them such that myFoo.fun(3) can be called as AllMemberFunctions!(typeof(myFoo))[idx](myFoo, 3). template AllMemberFunctions(T) { template

Re: Store struct tuple of alias and access members through it?

2018-04-07 Thread Alex via Digitalmars-d-learn
On Saturday, 7 April 2018 at 13:31:01 UTC, Timoses wrote: Simen was faster :) In my solution I simply ignore such things as functions... But there is the cool delegate creation approach in Simen's solution for this. I can handle arrays instead. :) And I got rid of tupelof acting on an

Re: Store struct tuple of alias and access members through it?

2018-04-07 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 7 April 2018 at 13:31:01 UTC, Timoses wrote: In the end I would like to accomplish the following: Provide access to contained bitfields and members of a struct in the order they appear in the struct via an index. The behavior of Type.tupleof in D seems a bit unfinished - they

Store struct tuple of alias and access members through it?

2018-04-07 Thread Timoses via Digitalmars-d-learn
(Please read at the very bottom what I'd like to achieve) Is it possible to return the member of a struct by its .tupleof index? I know that it would work on a struct value, but I'd like it to work on the type's tupleof: ``` struct S { int i;} S s; // below leads to: Error: need this for