On Tuesday, 26 July 2016 at 21:01:19 UTC, Ali Çehreli wrote:
On 07/26/2016 01:58 PM, ParticlePeter wrote:
On Tuesday, 26 July 2016 at 20:18:48 UTC, Steven Schveighoffer wrote:
...
void processMember( T, ignore... )() {
  foreach( member; __traits( allMembers, T )) { // this is a
compile-time list, so it's a static foreach.
foreach(i, arg; ignore ){ // i is the index into the ignore tuple static if( arg == member ) break; // break out of the foreach
loop, need to ignore it.
else static if(i + 1 == arg.length) // this is the last element!
      {
// process member here, generate e.g. setter function as string
mixin
      }
    }
  }
}

There is one problem with this approach, ignore might be empty (I should have mentioned it). Would you know a workaround for that case as well?

It should work for empty ignore. Can you show with a short example please.

Ali

First of all there seems to be a typo, it should not be:
  else static if(i + 1 == arg.length)

ignore must be used instead of arg, as arg.length is the length of a string:
  else static if(i + 1 == ignore.length)

if ignore is empty, its length is 0, so that the statement would always evaluate to false.

Btw, if ignore is not empty, only the last element (arg) is skipped.

Reply via email to