Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-16 Thread james.p.leblanc via Digitalmars-d-learn
On Monday, 16 August 2021 at 10:48:19 UTC, Alexandru Ermicioi wrote: On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote: To be honest, I am not exactly sure what is happening here. I am unfamiliar with the "(T : T[])" syntax ... need to read That is template argument secializatio

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-16 Thread Alexandru Ermicioi via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote: To be honest, I am not exactly sure what is happening here. I am unfamiliar with the "(T : T[])" syntax ... need to read That is template argument secialization. You're saying that T can be accept only types that are arrays of T

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-16 Thread Tejas via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:49:08 UTC, james.p.leblanc wrote: On Monday, 16 August 2021 at 06:42:48 UTC, Tejas wrote: If the code works, what's the problem? Hej Again, I was able to construct the working code shown above from help I obtained here in the forum and other resources. My ori

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:42:48 UTC, Tejas wrote: If the code works, what's the problem? Hej Again, I was able to construct the working code shown above from help I obtained here in the forum and other resources. My original code was not working ... but updated code is working fine ...

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread Tejas via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:36:02 UTC, james.p.leblanc wrote: On Monday, 16 August 2021 at 06:20:11 UTC, Tejas wrote: Maybe just write `T[]` in code rather than making it happen via the colon? I also have similar troubles, removing the default value always helped me. Can you show the c

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:20:11 UTC, Tejas wrote: Maybe just write `T[]` in code rather than making it happen via the colon? I also have similar troubles, removing the default value always helped me. Can you show the code where you're trying to apply this? Hej Tejas, Sure, here is

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread Tejas via Digitalmars-d-learn
On Monday, 16 August 2021 at 06:12:42 UTC, james.p.leblanc wrote: On Monday, 16 August 2021 at 05:26:00 UTC, Tejas wrote: If you're finding the spec too hard, please try Ali's book. I'm sharing the part on operator overloading below: http://ddili.org/ders/d.en/operator_overloading.html Pleas

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
On Monday, 16 August 2021 at 05:26:00 UTC, Tejas wrote: If you're finding the spec too hard, please try Ali's book. I'm sharing the part on operator overloading below: http://ddili.org/ders/d.en/operator_overloading.html Please ping if you still have problems; I'll then write a full program.

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread Tejas via Digitalmars-d-learn
On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc wrote: Greetings, I have been trying to get a working example of slice assignment operator overloading ... and am befuddled. From the spec (section 20.6.2), the code below appears: struct A { int opIndexAssign(int v)

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
On Sunday, 15 August 2021 at 21:28:53 UTC, james.p.leblanc wrote: On Sunday, 15 August 2021 at 21:15:02 UTC, Bastiaan Veelo wrote: On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc — Bastiaan. Bastiaan, Thanks once again, James On Sunday, 15 August 2021 at 21:28:53 UTC, james.p

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
On Sunday, 15 August 2021 at 21:15:02 UTC, Bastiaan Veelo wrote: On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc — Bastiaan. Bastiaan, Thanks kindly for your response! Unfortunately, I do not see what the program does. I mean A is a structure that has only functions. So, how

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread russhy via Digitalmars-d-learn
There is an example here: http://www.rosettacode.org/wiki/Multi-dimensional_array#D Look at the Matrix struct

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread ag0aep6g via Digitalmars-d-learn
On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc wrote: I have been trying to get a working example of slice assignment operator overloading ... and am befuddled. From the spec (section 20.6.2), the code below appears: struct A { int opIndexAssign(int v); // overloa

Re: Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread Bastiaan Veelo via Digitalmars-d-learn
On Sunday, 15 August 2021 at 20:41:51 UTC, james.p.leblanc wrote: struct A { int opIndexAssign(int v); // overloads a[] = v int opIndexAssign(int v, size_t[2] x); // overloads a[i .. j] = v int[2] opSlice(size_t x, size_t y); // overloads i .. j }

Getting a working example of opIndexAssign using opSlice ... have troubles ...

2021-08-15 Thread james.p.leblanc via Digitalmars-d-learn
Greetings, I have been trying to get a working example of slice assignment operator overloading ... and am befuddled. From the spec (section 20.6.2), the code below appears: struct A { int opIndexAssign(int v); // overloads a[] = v int opIndexAssign(int v, size_t[2]