On Sunday, 17 March 2019 at 10:49:03 UTC, aliak wrote:
Ah! Thanks! So next problem with that:
import std.stdio;
struct S(T) {
T value;
}
auto make(T)(inout auto ref T val) {
return inout(S!T)(val);
}
void main() {
writeln(make("hello") == S!string("hello"));
}
Error: Error: incompatible types for (make("hello")) ==
(S("hello")): immutable(S!(char[])) and S!string
I think that's just this bug (which is marked as a diagnostic
for some reason): https://issues.dlang.org/show_bug.cgi?id=19126
Thoughts on any workarounds?
For some reason, when you call `make("hello")`, the template
argument T is being inferred as char[] instead of string. (You
can see this by putting `pragma(msg, T)` in the body of make.) It
works if you instantiate make explicitly with
`make!string("hello")`.
This seems like a bug to me. If you remove inout from the code, T
is correctly deduced as string.