thanx you!

Im, Jihyuk icedac at g-nospam-mail.com
Wed Jan 30 03:41:47 PST 2008


>> template Foo( R, A, U  )
>
> Here's your problem. Since A and U are each single template parameters, 
> they can each assume precisely _one_ type.
> However, if you'll look, &plus_3 is a void delegate(int, int, int).
> This means that A'd have to be int, U also, and ... then we still got an 
> int left over that doesn't fit the template description.
> U... fixes this because it's a tuple and tuples can assume an arbitrary 
> number of types.
>
ooops! that was my errata too! my little programming experience in D led 
that err :)
maybe my brain sometimes let me remove '...' in template arguments.
anyway thank you!

"downs" <default_357-line at yahoo.de> wrote in message 
news:fnphi5$2eap$1 at digitalmars.com...
> Im, Jihyuk wrote:
>> thanx for your kind reply :)
>>
>> now I get to know the problem was a function template block should has 
>> one
>> definition inside.
>> but I think if the second code works fine, I think it's useful for
>> listing template parameter once and use various tempalte declaration but 
>> the
>> parameter deduced with parameters to
>> template function inside.
>>
>> Indeed my third code works fine for me :) your code contains string code
>> evaluation and mixin that's yet tough to me as c++ programmer
>>
>> But i found this simple code also emits duduction failure error
>>
>> [code]
>> template Foo( R, A, U  )
>
> Here's your problem. Since A and U are each single template parameters, 
> they can each assume precisely _one_ type.
> However, if you'll look, &plus_3 is a void delegate(int, int, int).
> This means that A'd have to be int, U also, and ... then we still got an 
> int left over that doesn't fit the template description.
> U... fixes this because it's a tuple and tuples can assume an arbitrary 
> number of types.
>
>> {
>>  R delegate (U)  Foo( R delegate ( A, U ) dg, A a )
>>  {
>>   R Foo_( U u )
>>   { R i; return i; }
>>   return &Foo2_;
>>  }
>> }
>>
>> void my_test()
>> {
>>  int plus_3( int a, int b, int c )
>>  {
>>   return a+b+c;
>>  }
>>
>>  Foo( &plus_3, 10 );  // deduction failure
>> }
>> [/code]
>>
>
> --downs 




More information about the Digitalmars-d-learn mailing list