Why is Phobos `Flag` so overthought ?
user1234
user1234 at 12.de
Mon May 6 17:55:49 UTC 2024
I think this just works:
```d
enum Flag : bool
{
no,
yes
}
alias AllowVancancy = Flag; // example usage
```
Also this is completion friendly whereas Phobos version does not
permit DCD completion as it's based on opDispatch.
Compare to phobos version:
```d
template Flag(string name) {
enum Flag : bool
{
no = false,
yes = true
}
}
struct Yes
{
template opDispatch(string name)
{
enum opDispatch = Flag!name.yes;
}
}
struct No
{
template opDispatch(string name)
{
enum opDispatch = Flag!name.no;
}
}
```
must be a reason but I cant find it RN ;)
More information about the Digitalmars-d-learn
mailing list