On Mon, 30 Nov 2009 23:13:23 +0100, Pelle Månsson <pelle.mans...@gmail.com> wrote:

Walter Bright wrote:
Bill Baxter wrote:
On Mon, Nov 30, 2009 at 1:00 PM, Walter Bright
   void opDispatch(string name, T...)(T values...)
                                              ^^^

You didn't use to have to do that with variadic templates.  Is that
also a new change in SVN?
 I believe it was always like that.

What do you mean? Not the D I played with?

void test1(T...)(T ts) {
     writeln(ts); //works as expected
}
void test2(string s, T...)(T ts) {
     writeln(s);  // requires manual specifying of each type
     writeln(ts); // e.g. test2!("foo", int, int)(1,2)
}
void test3(string s, T...)(T ts...) {
     writeln(s);  // silently dies when called with
     writeln(ts); // test3!("foo")(1,2,3,4) in v2.034
}

It would seem Walter is right, but only for opDispatch. This compiles
fine. If you want compile errors, move the ellipsis around:


struct foo {
        void opDispatch( string name, T... )( T value... ) {
        }
        
        void bar( T... )( T args ) {
        }
}

void main( ) {
        foo f;
        f.bar( 3 );
        f.baz( 3.14 );
}

--
Simen

Reply via email to