opApply outside of struct/class scope

2014-08-10 Thread Freddy via Digitalmars-d-learn
I'm trying to implement a opApply outside of struct scope struct A{ int[] arr; } int opApply(ref A a,int delegate(ref int) dg){ return 0; } void main(){ A a; foreach(i;a){//i just want it to compile } } when i try compiling, the

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 18:45:00 UTC, Freddy wrote: Is there any why i can put a opApply outside of a struct scope No overloaded operators in D can be put outside of a struct or class. They have to be member functions. - Jonathan M Davis

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 18:58:50 UTC, Jonathan M Davis wrote: No overloaded operators in D can be put outside of a struct or class. They have to be member functions. If I remember right, opApply was somewhat broken and only worked correctly in a few cases. But that was 18 months ago, a

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 19:01:18 UTC, Era Scarecrow wrote: On Sunday, 10 August 2014 at 18:58:50 UTC, Jonathan M Davis wrote: No overloaded operators in D can be put outside of a struct or class. They have to be member functions. If I remember right, opApply was somewhat broken and only

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 21:57:29 UTC, Jonathan M Davis wrote: I'm not aware of opApply being broken, but I never use it, I remember very specifically it was brought up, that opApply was not working correctly and you could only use it with a very specific cases because... the

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Sunday, 10 August 2014 at 22:03:28 UTC, Era Scarecrow wrote: I remember very specifically it was brought up, On Wed, Jul 09, 2014 at 03:16:37PM -0700, H. S. Teoh via Digitalmars-d wrote: Judging from this, a big missing piece of the current implementation is the actual enforcement of

Re: opApply outside of struct/class scope

2014-08-10 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, 10 August 2014 at 22:03:28 UTC, Era Scarecrow wrote: On Sunday, 10 August 2014 at 21:57:29 UTC, Jonathan M Davis wrote: I'm not aware of opApply being broken, but I never use it, I remember very specifically it was brought up, that opApply was not working correctly and you could

Re: opApply outside of struct/class scope

2014-08-10 Thread Era Scarecrow via Digitalmars-d-learn
On Monday, 11 August 2014 at 02:03:15 UTC, Jonathan M Davis wrote: IIRC, opApply doesn't play well with various attributes, but I don't remember the details. That's the only issue with opApply that I'm aware of. It looks like you'll have to go digging into those other threads if you want to