Xref: digitalmars.com digitalmars.D:22525 Original Text: Why there is no .dup property of AAs? And if .dup is used for array of, lets say, stucts that have another array as member is it duplicated too or if I modify it in the dup array the original will be modified too? foo[bar] dup( foo[bar] arr ) { foo[bar] copy; foreach( bar key, foo val ; arr ) copy[key]=val; return copy; } -------------------------------------------------------- 泛型实现 template dup(Key, Value) { Value[Key] dup(Value[Key] aa) { Value[Key] copy; foreach( Key key, Value val ; aa ) { copy[key]=val; } return copy; } }

评论