dynamic classes and duck typing
Denis Koroskin
2korden at gmail.com
Mon Nov 30 14:41:44 PST 2009
On Tue, 01 Dec 2009 00:00:23 +0300, Walter Bright
<newshound1 at 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).
More information about the Digitalmars-d
mailing list