On 17/03/2019 18:34, Kagamin via Digitalmars-d-learn wrote:
On Saturday, 16 March 2019 at 14:57:35 UTC, Paul Backus wrote:
This code fails to compile if you change `auto s2` to `const s2`--in other
words, it has the same problem as the original example.
Maybe there's not much need for qualifie
On Sunday, 17 March 2019 at 20:23:44 UTC, Paul Backus wrote:
On Sunday, 17 March 2019 at 10:49:03 UTC, aliak wrote:
[...]
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 th
On Sunday, 17 March 2019 at 17:22:13 UTC, Kagamin wrote:
struct S(T) {
T value;
bool opEquals(U:S!V,V)(in U r) const
{ return value==r.value; }
}
Hmm, that actually works for opEquals. But now you just hit the
same problem with some other construct, unfortunately:
auto x = [make(
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: incom
On Saturday, 16 March 2019 at 14:57:35 UTC, Paul Backus wrote:
This code fails to compile if you change `auto s2` to `const
s2`--in other words, it has the same problem as the original
example.
Maybe there's not much need for qualifiers anyway.
struct S(T) {
T value;
}
auto make(T)(ref T
struct S(T) {
T value;
bool opEquals(U:S!V,V)(in U r) const
{ return value==r.value; }
}
On Saturday, 16 March 2019 at 03:49:26 UTC, Paul Backus wrote:
On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote:
Anyone knows how to make this work?
You need an explicit `inout` on the return value of `make`:
auto ref make(T)(inout auto ref T value) {
return inout(S!T)(value);
}
Ah
On Saturday, 16 March 2019 at 11:55:56 UTC, spir wrote:
I think (but may be wrong) that you don't need inout here,
since a plain 'ref' will (and does) work. This is accepted by
me (I added vars to make the code clearer to myself):
struct S(T) {
T value = T.init;
}
auto ref make(T)(ref T v
PS: the chapter of Ali Çehreli's book on func args is great:
http://ddili.org/ders/d.en/function_parameters.html
diniz
On 16/03/2019 04:49, Paul Backus via Digitalmars-d-learn wrote:
On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote:
Anyone knows how to make this work?
You need an explicit `inout` on the return value of `make`:
auto ref make(T)(inout auto ref T value) {
return inout(S!T)(value);
}
On Friday, 15 March 2019 at 23:57:15 UTC, aliak wrote:
Anyone knows how to make this work?
You need an explicit `inout` on the return value of `make`:
auto ref make(T)(inout auto ref T value) {
return inout(S!T)(value);
}
This is the set up I have, and I'm not sure how to get the main
function at the bottom to compile. The error in the code below is
that it cannot implicitly convert an inout(C) to a C in the
constructor of S(T).
If you remove the constructor that takes an inout then you get a
"cannot deduce fu
12 matches
Mail list logo