Help with Template Code
John Demme
me at teqdruid.com
Fri Mar 30 19:15:33 PDT 2007
Hey all!
There's a particular problem I'm trying to solve using templates. I don't
see a reason that the compiler couldn't do this, but I'm not certain I can
do it with templates yet.
Here's a slightly simplified pseudo-code-ish version of what I want to do:
T inst(T : struct)(T.tupleof t);
Yes- this makes no sense, so let me describe. I want to create a templated
function wherein the template argument is a struct... OK, that's easy.
Next, I want the parameters of the function to be the types in the struct.
For example, if I have the following struct:
struct Foo {
int a;
float b;
}
then the following call:
Foo f = inst!(Foo)(5, 8.26)
would pass the Tuple!(int,float)(5, 8.26) into the inst function. No, it's
not OK to add stuff so the calling code, but the inst function can be as
ugly as necessary.
I feel like this should be possible, but I don't know how... Any ideas?
Thanks
--
~John Demme
me at teqdruid.com
http://www.teqdruid.com/
More information about the Digitalmars-d-learn
mailing list