template magic

Jesse Phillips jessekphillips+D at gmail.com
Tue Jan 25 11:30:52 PST 2011

spir Wrote:

> On 01/25/2011 06:03 PM, Simen kjaeraas wrote:
> >
> > Of course, given a non-template function, it is impossible to safely
> > pass a function to it.
> Dont you count this as typesafe function passing?
> 	void writeRounding (int function (float) roundingScheme) {...}

He means accepting any function no matter the return type or arguments. With templates you can do this and it will remain type safe, non-templates can't do this while remaining type safe. But then again you shouldn't really expect an arbitrary function to be type safe at runtime, unless of course you specify the types it must be, but then it isn't arbitrary in that context...

More information about the Digitalmars-d-learn mailing list