D lang newbie ..what does syntax func_name !() represent ??

Adam D. Ruppe destructionator at gmail.com
Sat Jul 25 00:42:04 UTC 2020


On Saturday, 25 July 2020 at 00:36:19 UTC, Andy Balba wrote:
> I keep running into statements like  `func_name!()`
> and cant figure out what !() could possibly mean .

That's a template instance, like foo<int> in C++.

Though D can pass a lot more than just types to its templates so 
you might see like foo!"bar" too, but it is the same idea - 
passing that string as a template argument to foo.

BTW if there is just one simple argument, you can leave the 
parentehsis out like I did there.

to!int

is the same as

to!(int)

which is like

to<int>

in C++.


More information about the Digitalmars-d mailing list