IFTI with constant args, is this already possible?

Don Clugston dac at nospam.com.au
Tue Jan 30 23:55:04 PST 2007


Chad J wrote:
> 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";

There's no syntax sugar for this at present. (Though I've proposed it, 
and there are indications that it will happen).
But:

bigAssInteger = toBigInt!("3420894398526094609987620490236001914309690234");

is currently possible.

Until we get early discard of templates, it's not really a good idea 
right now because compilation is slow while the compiler generates an 
enormous obj file full of junk.


More information about the Digitalmars-d-learn mailing list