On 03/18/12 12:05, Derek wrote: > On Sun, 18 Mar 2012 21:36:46 +1100, FeepingCreature > <default_357-l...@yahoo.de> wrote: > > >> why would you do that > > To make coding easier to write AND read. > >> what do you want to _do_ > > Infer template arguments from the data types presented in the data values > supplied on the instantiation statement. > >> it sounds like you're frantically trying to nail templates into a shape that >> they really really really aren't meant for > > I assumed D templates were a type of template; a model for real runnable code > that the compiler can instantiate based on the arguments supplied.
Yes but you keep trying to pass runtime arguments to a compiletime construct. I think you understand what templates are but not how to use them. > >> in any case what is wrong with auto add(T)(T t) { return t[0] + t[1]; } > > It doesn't work. > Okay, let's try this. template add(T) { template add(U...) { T add(U u) { T res; foreach (entry; u) res += cast(T) entry; return res; } } } add!int(2, 3, 4.0, 5.0f);