Re: inout, delegates, and visitor functions.

2015-10-24 Thread Sebastien Alaiwan via Digitalmars-d-learn
Hi ponce, Thanks for your suggestion. I think I may have found the beginning of a solution: class E { import std.traits; void apply(this F, U)(void delegate(U e) f) if(is(Unqual!U == E)) { f(this); } int val; } int main() { void setToZero(E e) { e.val = 0; }

Re: inout, delegates, and visitor functions.

2015-10-24 Thread ponce via Digitalmars-d-learn
On Saturday, 24 October 2015 at 11:28:17 UTC, Sebastien Alaiwan wrote: Hi ponce, Thanks for your suggestion. I think I may have found the beginning of a solution: class E { import std.traits; void apply(this F, U)(void delegate(U e) f) if(is(Unqual!U == E)) { f(this); } int

inout, delegates, and visitor functions.

2015-10-24 Thread Sebastien Alaiwan via Digitalmars-d-learn
Hi all, I'm trying to get the following code to work. (This code is a simplified version of some algebraic type). Is it possible to only declare one version of the 'apply' function? Or should I declare the const version and the non-const version? I tried using "inout", but I got the following

Re: inout, delegates, and visitor functions.

2015-10-24 Thread ponce via Digitalmars-d-learn
On Saturday, 24 October 2015 at 08:51:58 UTC, Sebastien Alaiwan wrote: Hi all, I'm trying to get the following code to work. (This code is a simplified version of some algebraic type). Is it possible to only declare one version of the 'apply' function? Or should I declare the const version