Can I use a delegate as a template parameter? (Issue 2962?)

Simen kjaeraas simen.kjaras at gmail.com
Wed Mar 30 11:20:32 PDT 2011


On Wed, 30 Mar 2011 14:07:51 +0200, Magnus Lie Hetland  
<magnus at hetland.org> wrote:

> A while ago, I wrote something like this:
>
> void C(alias foo)() {
>     void bar() {
>         foo();
>     }
>     bar();
> }
>
> void B(T)(uint x=2) {
>     uint foo() {
>         return x;
>     }
>     C!foo();
> }
>
> Also, aside from the erratic DMD behavior, I'm guessing my code might be  
> invalid, and shouldn't have worked in the first place. After all, x is a  
> run-time argument, and is part of foo, which functions as a compile-time  
> argument. I mean, the set-up *could* work (and, in fact, generally seems  
> to do so), but it might be a bit problematic?

Don't worry, that's supposed to work.



-- 
Simen


More information about the Digitalmars-d-learn mailing list