const Propagation

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Mon Dec 29 06:30:15 PST 2014


On 12/29/14 9:18 AM, Steven Schveighoffer wrote:

> Static-if applies to generic coding, i.e. templates. A template function
> may work, but I don't think you even need static if:
>
> class Hugo { ... }
>
> void blah(T)(T obj, void function(T t) f) if(T : Hugo) { f(obj);}

um...

blah(T : Hugo)(T obj, void function(T t) f) { f(obj); }

Maybe this will work better, but still untested :) You may need T : 
const(Hugo).

-Steve


More information about the Digitalmars-d mailing list