Template instantiation

Trass3r mrmocool at gmx.de
Fri Mar 20 08:35:24 PDT 2009

Got the following code:

public LuaState wrapClass (T) (T instance)
	auto ptr = cast (T *) newUserdata ( (T *).sizeof);
	*ptr = instance;

	loadClassMetatable (typeid(T).toString);
	setMetatable (-2);
	return this;

Am I right in assuming that a different wrapClass will be created in the 
final executable for each template instantiation (e.g. calls with class 
A,B,C,... instances) and would thus bloat up the executable a bit when 
used with many classes?

Apart from that, couldn't you just use wrapClass (Object instance)? In 
the end each class instance pointer takes up the same amount of memory?!

More information about the Digitalmars-d-learn mailing list