std.algorithm.countUntil and alias
Anton Pastukhov
caffeine9999 at mailbox.org
Wed Oct 23 12:32:09 UTC 2024
I'm struggling with this code. Why `countUntil` won't work with
aliases?
```
import std.traits : EnumMembers;
import std.algorithm : countUntil;
enum Test: string {
One = "one",
Two = "two",
Three = "three"
}
struct MyStruct {
Test test = Test.Three;
}
void main() {
auto myStruct = MyStruct();
// this works as expected
auto idx = countUntil!(e => e ==
myStruct.test)([EnumMembers!Test]);
// this triggers error: app.d(22): Error: none of the
overloads of template `std.algorithm.searching.countUntil` are
callable using argument types `!((e) => e == myAlias)(Test[])`
alias myAlias = MyStruct.test;
auto idx2 = countUntil!(e => e ==
myAlias)([EnumMembers!Test]);
}
```
More information about the Digitalmars-d-learn
mailing list