template mixin in class is virtual function?

div0 div0 at users.sourceforge.net
Fri May 21 12:35:05 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

strtr wrote:
> Or more to the point:
> 
> Can (Class) template mixin functions be devirtualized by the compiler or do I (as
> optimization) need to manually copy paste the boiler plate code?

You can just wrap the mixin in a final block:

import std.stdio;

template bar(T) {
	void test(T t) {
		writefln("t: %s", t);
	}
}

class foo {
	final {
		mixin bar!(int);
	}
}

int main(){
	scope f = new foo;
	f.test(3);
	return 0;
}

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFL9uBpT9LetA9XoXwRAv83AKDNlqLgcI7C0g5x5t6CnUq82C5/xACghKUF
p9whtC6i/L7jrJyuLg+RZWo=
=BGBu
-----END PGP SIGNATURE-----


More information about the Digitalmars-d-learn mailing list