opDispatch and template parameters
Guillaume B.
guillaume.b.spam at spam.ca
Mon Sep 13 17:57:04 PDT 2010
Oh, well: http://d.puremagic.com/issues/show_bug.cgi?id=4856
Guillaume
Guillaume B. 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")();
> }
> ====
>
> This compiles fine but if I remove the commented line, dmd (v2.048) tells
> me:
>
> test.d(13): Error: template instance opDispatch!("testName") does not
> match template declaration opDispatch(string name,string otherName)
>
> The error seems OK for a "normal" function, but for opDispatch, it seems
> limiting to me. Is this a bug?
>
> Here's an other, similar, test:
>
> ====
> module test.d;
>
> import std.stdio;
>
> struct DispatchTest {
> void opDispatch(string name, T)(T t) {
> writeln(name, ":", T.stringof);
> }
> }
>
> void main() {
> DispatchTest t;
> //t.testName!(DispatchTest)(t);
> t.testName(t);
> }
> ====
>
> Which gives, when uncommenting:
>
> test.d(13): Error: template instance opDispatch!("testName") does not
> match template declaration opDispatch(string name,T)
>
> So bug or not?
>
> Guillaume
More information about the Digitalmars-d
mailing list