== Quote from Jacob Carlborg (d...@me.com)'s article > Is it supposed to possible to mixin a constructor? The code below > doesn't compile. The error: is "main.d(23): Error: constructor > main.A.this() does not match parameter types (int) > main.d(23): Error: expected 0 arguments, not 1" > template C () > { > this (int i) > { > } > } > class A > { > mixin C; > this () > { > } > } > void main () > { > auto a = new A(3); > }
I'm not sure exactly why this example doesn't work, but it looks like a bug. Please file. If you just want to insert a bunch of boilerplate without any parameters, you probably should try a string mixin instead. The following does work: enum string C = q{ this (int i) { } }; class A { mixin(C); this () { } } void main () { auto a = new A(3); }