| Thread overview | |||||||
|---|---|---|---|---|---|---|---|
|
November 03, 2006 Extracting function param types using variadic templates | ||||
|---|---|---|---|---|
| ||||
Hmm.
I can do this:
void variadic(T...)(T args){}
variadic(1, 2, 3);
This:
void returnType(T)(T delegate() dg){}
returnType(delegate int(){ return 0; });
Even this:
void returnAndArg(T, U)(T delegate(U) dg){}
returnAndArg(delegate int(bool b){ return 0; });
But not:
void returnAndArgs(T, U...)(T delegate(U) dg){}
returnAndArgs(delegate int(bool b){ return 0; });
!
One can dream, no?
Is there maybe some other way to get at the parameter types of a function as a tuple, using variadic magic?
| ||||
November 03, 2006 Re: Extracting function param types using variadic templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > Is there maybe some other way to get at the parameter types of a function as a tuple, using variadic magic? How about this stuff: http://www.dsource.org/projects/pyd/browser/trunk/infrastructure/meta ? | |||
November 04, 2006 Re: Extracting function param types using variadic templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Tom S | "Tom S" <h3r3tic@remove.mat.uni.torun.pl> wrote in message news:eigch3$ilf$1@digitaldaemon.com... > Jarrett Billingsley wrote: >> Is there maybe some other way to get at the parameter types of a function as a tuple, using variadic magic? > > How about this stuff: http://www.dsource.org/projects/pyd/browser/trunk/infrastructure/meta ? But that's basically using my third example, i.e. void returnAndArg(T, U)(T delegate(U) dg){} returnAndArg(delegate int(bool b){ return 0; }); But with many specializations of the template, one for each number of params. The point of using variadic templates is removing the need to manually create a specialization for each number of things you want in the typelist. With the automatic tuple deduction that I wish existed, the FuncMeta.d module would become about 80 lines of code, and it would be able to support any number of arguments. | |||
November 04, 2006 Re: Extracting function param types using variadic templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | Jarrett Billingsley wrote: > "Tom S" <h3r3tic@remove.mat.uni.torun.pl> wrote in message news:eigch3$ilf$1@digitaldaemon.com... >> Jarrett Billingsley wrote: >>> Is there maybe some other way to get at the parameter types of a function as a tuple, using variadic magic? >> How about this stuff: http://www.dsource.org/projects/pyd/browser/trunk/infrastructure/meta ? > > But that's basically using my third example, i.e. > > void returnAndArg(T, U)(T delegate(U) dg){} > returnAndArg(delegate int(bool b){ return 0; }); > > But with many specializations of the template, one for each number of params. The point of using variadic templates is removing the need to manually create a specialization for each number of things you want in the typelist. With the automatic tuple deduction that I wish existed, the FuncMeta.d module would become about 80 lines of code, and it would be able to support any number of arguments. > > This was approximately the first thing I tried doing with variadic templates. I was very saddened to see that it doesn't work. -- Kirk McDonald Pyd: Wrapping Python with D http://pyd.dsource.org | |||
November 04, 2006 Re: Extracting function param types using variadic templates | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kirk McDonald | Kirk McDonald wrote:
> This was approximately the first thing I tried doing with variadic templates. I was very saddened to see that it doesn't work.
I agree, and I'll break out the hammer & tongs and see if I can make it work.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply