A look inside "filter" function defintion

frame frame86 at live.com
Tue Aug 2 14:24:50 UTC 2022


On Tuesday, 2 August 2022 at 12:39:41 UTC, pascal111 wrote:

> Instantiation seems some complicated to me. I read "If a 
> template contains members whose name is the same as the 
> template identifier then these members are assumed to be 
> referred to in a template instantiation:" in the provided link, 
> but I'm still stuck. Do you have a down-to-earth example for 
> beginners to understand this concept?

There are obvious examples direct below.

Where do you get stuck?

Maybe this helps:

A template can be seen as a static struct too, so you can access 
its members with the scope operator "." and if there is only one 
member of the same name as the template ifself, the compiler auto 
completes it to this member.

You could always write out 
`name!(someTemplateArg).name(someRuntimeArg)`, we just prefer the 
short syntax `name!(someTemplateArg)(someRuntimeArg)` or 
`name(someRuntimeArg)` (if there are no template arguments or it 
could be auto deducted by the compiler). The last syntax shows 
that it can be called as a normal function while in fact it's a 
template.


More information about the Digitalmars-d-learn mailing list