Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-18 Thread novice2 via Digitalmars-d-learn
On Monday, 18 March 2024 at 10:05:43 UTC, novice2 wrote: On Monday, 18 March 2024 at 08:50:42 UTC, rkompass wrote: Or are the types T and S are put on the stack like ordinary arguments and the usage of arg1 and arg2 within the function is enveloped in switches that query these Types? IMHO, on

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-18 Thread novice2 via Digitalmars-d-learn
On Monday, 18 March 2024 at 08:50:42 UTC, rkompass wrote: Given the types S and T in say `templfunc(S, T)(S arg1, T arg2) {}` represent 2 different actual types in the program, does that mean that there are 4 versions of the `templfunc` function compiled in? (This was the C++ way iirc). IMHO,

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-18 Thread rkompass via Digitalmars-d-learn
@bachmeier You're not the first one. There's no technical reason for the restriction. It's simply a matter of being opposed by those who make these decisions on the basis that it's the wrong way to program or something like that. Here is a recent thread: https://forum.dlang.org/post/ikwphfwevg

Re: How to make a struct containing an associative array to deeply copy (for repeated usage in foreach) ?

2024-03-18 Thread rkompass via Digitalmars-d-learn
To solve the problem with the 1-variable and 2-variable versions of foreach I tried opApply and found that the compiler prefers it over opSlice and opIndex() (the latter without argument). My code: ```d int opApply(int delegate(Variant) foreachblock) const { int result