How to copy object of class A to another object of class B?

zhmt via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jan 28 06:50:41 PST 2015


The final version works well:

void copyObj(SRC,DEST)(ref SRC src,ref DEST dest)
{
	foreach (i, type; typeof(SRC.tupleof)) {
		__traits(getMember, dest, SRC.tupleof[i].stringof) =  
__traits(getMember, src, SRC.tupleof[i].stringof);
	}
}

thank u , @Marc Schütz .


More information about the Digitalmars-d-learn mailing list