deep copying / .dup / template object.dup cannot deduce function from argument types

Robert M. Münch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 13 10:54:24 PST 2015


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?

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list