Test case:
----
import std.typecons, std.range;
struct S {
void put(int[] a){}
void put(int n){}
}
void main() {
S s;
put(s, 1); // OK
put(s, [1]); // OK
auto rs = RefCounted!S();
put(rs, 1); // doesn't work
put(rs, [1]); // doesn't work
}
----
To fix this issue, both Phobos and dmd needs to be fixed.
- std.traits.hasMembers doesn't see the members through alias this.
- There is no way to check whether a type T has a member xxx or not, while avoiding UFCS.
I've conceived following technique, but doesn't work with current dmd.
struct T { void put(){} }
alias T.put X; // Type.member doesn't test UFCS,
// but getting symbol of xxx would work!
struct S { T t; alias t this; }
alias S.put X; // Getting symbol through alias this doesn't work...
I think we need to fix bug 4617.