Re: opApply with/without ref

2012-01-13 Thread bearophile
H. S. Teoh: void opApply(int delegate(ref uint n) cb) const { Use const ref: void opApply(int delegate(const ref uint n) cb) const { Bye, bearophile

Re: opApply with/without ref

2012-01-13 Thread H. S. Teoh
On Fri, Jan 13, 2012 at 07:36:40AM -0500, bearophile wrote: H. S. Teoh: void opApply(int delegate(ref uint n) cb) const { Use const ref: void opApply(int delegate(const ref uint n) cb) const { [...] Thanks a lot! That works like a charm! T -- Let's not fight disease by

Re: opApply with/without ref

2012-01-13 Thread Steven Schveighoffer
On Thu, 12 Jan 2012 22:49:49 -0500, H. S. Teoh hst...@quickfur.ath.cx wrote: Hi all, I'm experimenting with overloading foreach() with opApply, and I found that this code doesn't compile: class C { void opApply(int delegate(uint n) cb) const {

opApply with/without ref

2012-01-12 Thread H. S. Teoh
Hi all, I'm experimenting with overloading foreach() with opApply, and I found that this code doesn't compile: class C { void opApply(int delegate(uint n) cb) const { ... } } unittest { auto c = new