On Tue, 01 Dec 2009 00:00:23 +0300, Walter Bright <newshou...@digitalmars.com> wrote:

Álvaro Castro-Castilla wrote:
It does. Shouldn't this work also?
 struct foo {
    void opDispatch( string name, T... )( T values ) {     }   }
void main( ) { foo f;
    f.bar( 3.14 );
}

Declare as:

     void opDispatch(string name, T...)(T values...)
                                                ^^^

What? I am using code like Álvaro posted all the time, whereas your syntax doesn't even work (according to my test):

void foo(T...)(T values)
{
}

foo(42);

Error: template test.foo(T...) does not match any function template declaration Error: template test.foo(T...) cannot deduce template function from argument types !()(int)

I wonder why it works for opDispatch (if it does, as you say).

Reply via email to