DIP 88: Simple form of named parameters

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 24 05:33:50 PST 2016


On 2016-01-24 14:24, Michel Fortin wrote:

> On further thought, how do you make templates with specialization take
> named arguments?
>
>      template TFoo(T)        { ... } // #1
>      template TFoo(T : T[])  { ... } // #2
>      template TFoo(T : char) { ... } // #3
>
> My guess would be this:
>
>      template TFoo(T:)        { ... } // #1
>      template TFoo(T: : T[])  { ... } // #2
>      template TFoo(T: : char) { ... } // #3
>
> ... but it makes the declaration a bit strange.

Yes. Rule 7 covers that. There's also an example showing the syntax, 
search for "Template specialization with named parameter". Yes, it does 
look a bit strange.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list