Flag & byLine confusion.
Rekel
paultjeadriaanse at gmail.com
Sun Dec 20 14:07:56 UTC 2020
Thanks for all the help! This makes it make a lot more sense now,
I'm surprised it's not part of the dlang tour.
> The template parameter serves to make Flag!"foo" a distinct
> type from Flag!"bar".
Does this mean other flag yes's will not be accepted?
> https://dlang.org/spec/operatoroverloading.html#dispatch
Also regarding the other examples given, why does Phobos use
templating so heavily, in situation in which I am totally
confused as to why generics would be necessary.
I seem to be totally confused as to how this template system
works. It was introduced as a kind of generic, like in Java, but
things like 'string s' seem to me like parameters.
For example;
```
class C
{
void opDispatch(string s)(int i)
{
writefln("C.opDispatch('%s', %s)", s, i);
}
}
```
I'm pretty sure I'm confusing something, though I don't see the
point of using this instead of something like 'opDispatch(string
s, int i)`?
I also came across a similar thing in the File.byLine
documentation.
(https://dlang.org/library-prerelease/std/stdio/file.by_line.html)
More information about the Digitalmars-d-learn
mailing list