Simen kjaeraas wrote: > Guillaume B. <guillaume.b.s...@spam.ca> wrote: > >> Hi, >> >> Is this usage of opDispatch supposed to work: >> >> ==== >> module test.d; >> >> import std.stdio; >> >> struct DispatchTest { >> void opDispatch(string name, string otherName)() { >> writeln(name, ":", otherName); >> } >> } >> >> void main() { >> DispatchTest t; >> //t.testName!("testOtherName")(); >> t.opDispatch!("testName", "testOtherName")(); >> } >> ==== >> [...] > > Sorry for not noticing this post before. This is not a bug. The correct > way to do what you want is this: > > > module foo; > > import std.stdio; > > struct test { > template opDispatch( string name ) { > void opDispatch( string other )( ) { > writeln( name, ", ", other ); > } > } > } > > void main( ) { > test t; > t.foo!( "Hey!" )( ); > } >
Wow! That's a nice trick! Seems like I'll have to be carefull when defining opDispatch! Guillaume