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

rkompass rkompass at gmx.de
Thu Mar 14 16:12:00 UTC 2024


Hello @monkyyy,

thank you for your help. I will study and try your code.

Meanwhile I have found that I can add this function into the 
struct:

```d
// postblit constructor, see
// 
https://stackoverflow.com/questions/38785624/d-struct-copy-constructor
	this(this) {
		string[string] ndct;
		foreach (k; dct.keys)  // do a deep copy
			ndct[k] = dct[k];
		dct = ndct;
	}
```



More information about the Digitalmars-d-learn mailing list