Error: field r must be initialized in constructor, because it is nested struct
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jun 3 16:27:31 PDT 2015
Pretty standard thing doesn't work and I can't find it on bugzilla:
import std.algorithm;
struct Foo(R)
{
R r;
this(R r) // <-- Compilation error
{}
}
auto foo(R)(R r)
{
return Foo!R(r);
}
void main()
{
auto arr = [1];
arr.map!(i => i).foo;
}
I was actually trying to dispatch the construction to a separate function:
this(R r) // <-- Still error
{
init(r);
}
void init(R r)
{
this.r = r;
}
(I remember this latter issue having been discussed recently.)
Ali
More information about the Digitalmars-d-learn
mailing list