cannot use local f as parameter to non-global template

Paul Backus snarwin at gmail.com
Sat Dec 8 14:21:01 UTC 2018


On Saturday, 8 December 2018 at 09:57:29 UTC, aliak wrote:
> This compiles fine. However, if I change the match template to:
>
> template match(handlers...) {
>     auto match(alias f)(Holder!f holder) {
>         return handlers[0](holder);
>     }
> }
>
> Notice the template parameter of the eponymous match is an 
> alias now, and the function parameter is typed as a Holder.

The "de-sugared" version of your second `match` function looks 
like this:

template match(handlers...) {
     template match(alias f) {
         auto match(Holder!f holder) {
             return handlers[0](holder);
         }
     }
}

Notice the second template nested inside the first. That's the 
"non-gloal template" the error is complaining about.


More information about the Digitalmars-d-learn mailing list