On Sunday, 13 December 2015 at 18:54:24 UTC, Robert M. Münch
wrote:
Hi, I just wanted to naively copy an object and used:
a = myobj.dup;
and get the following error messages:
source/app.d(191): Error: template object.dup cannot deduce
function from argument types !()(BlockV), candidates are:
/Library/D/dmd/src/druntime/import/object.d(1872):
object.dup(T : V[K], K, V)(T aa)
/Library/D/dmd/src/druntime/import/object.d(1908):
object.dup(T : V[K], K, V)(T* aa)
/Library/D/dmd/src/druntime/import/object.d(3246):
object.dup(T)(T[] a) if (!is(const(T) : T))
/Library/D/dmd/src/druntime/import/object.d(3262):
object.dup(T)(const(T)[] a) if (is(const(T) : T))
/Library/D/dmd/src/druntime/import/object.d(3273):
object.dup(T : void)(const(T)[] a)
Hmm... so, is .dup not the way to go?
And, am I correct, that a deep-copy needs to be hand coded?
`dup` is an array method; it only works on arrays.
Structs are value types, so `a = b` will "duplicate" a struct.
For classes, you will need to define your own clone function.