IFTI with constant args, is this already possible?

Chad J gamerChad at _spamIsBad_gmail.com
Tue Jan 30 19:38:37 PST 2007


So suppose I have a function template, one that is supposed to be 
instantiated via IFTI.  Then, the user supplies an argument that is 
constant (ex: foo(42,"cat")).  Is there any way that I can grab those 
constant arguments at compile time and use them to do compile time 
computation?  Even better, can I do it in variadic templates?

I'm envisioning a situation like this:

// the string-to-integer conversion is done at compile time
bignum bigAssInteger = "3420894398526094609987620490236001914309690234";

...

struct bignum
{
	ulong[] data;

	...
	
	void opAssign(char[] value)()
	{
		data = toBigInt!(value);
	}
}

or something like that.  BigNums come to mind as a simple example, but 
I've run into this sort of thing other times too.  Hard to put it down 
since I don't know if it's even possible, much less what it would look 
like.


More information about the Digitalmars-d-learn mailing list