Re: iterating through members of bitfields

2017-01-21 Thread Nestor via Digitalmars-d-learn
Thank you both!

Re: iterating through members of bitfields

2017-01-20 Thread Ali Çehreli via Digitalmars-d-learn
On 01/19/2017 05:21 PM, Nestor wrote: On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote: I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works.

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 15:04, Nestor пишет: Where does one define the size for a field using AliasSeq, and in this example, why does it take 1 bit if the size is not declared anywhere? Something like that https://goo.gl/zV8T23

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 15:04, Nestor пишет: On Friday, 20 January 2017 at 08:13:08 UTC, drug wrote: Something like that https://goo.gl/C4nOqw Because you generate code iterating over AliasSeq you can do almost everything you need - for example generate setters/getters. Interesting site, I wouldn't

Re: iterating through members of bitfields

2017-01-20 Thread Nestor via Digitalmars-d-learn
On Friday, 20 January 2017 at 08:13:08 UTC, drug wrote: Something like that https://goo.gl/C4nOqw Because you generate code iterating over AliasSeq you can do almost everything you need - for example generate setters/getters. Interesting site, I wouldn't implemente something like this in a

Re: iterating through members of bitfields

2017-01-20 Thread drug via Digitalmars-d-learn
20.01.2017 04:21, Nestor пишет: On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote: I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works. Interesting,

Re: iterating through members of bitfields

2017-01-19 Thread Nestor via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 12:52:56 UTC, drug wrote: I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works. Interesting, could you provide a working

Re: iterating through members of bitfields

2017-01-18 Thread drug via Digitalmars-d-learn
I've "solved" the same problem by using AliasSeq to generate bitfields so that for iterating over bitfields I can iterate over alias sequence and mixin code. Not very good but it works.

Re: iterating through members of bitfields

2017-01-18 Thread Nestor via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 01:15:05 UTC, Ali Çehreli wrote: Not available but it should be possible to parse the produced code: import std.bitmanip; string makeBitFieldPrinter(string fieldImpl) { return q{ void printBitFields() const { import std.stdio: writeln;

Re: iterating through members of bitfields

2017-01-17 Thread Ali Çehreli via Digitalmars-d-learn
On 01/17/2017 04:37 PM, Nestor wrote: Hi, I was just looking at an interesting function from http://codepad.org/lSDTFd7E : void printFields(T)(T args) { auto values = args.tupleof; size_t max; size_t temp; foreach (index, value; values) { temp = T.tupleof[index].stringof.length;

iterating through members of bitfields

2017-01-17 Thread Nestor via Digitalmars-d-learn
Hi, I was just looking at an interesting function from http://codepad.org/lSDTFd7E : void printFields(T)(T args) { auto values = args.tupleof; size_t max; size_t temp; foreach (index, value; values) { temp = T.tupleof[index].stringof.length; if (max < temp) max = temp; }