A functor-based curry: YET I HAVE PROBLEM
downs
default_357-line at yahoo.de
Wed Jan 30 01:54:00 PST 2008
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