immutable / inout / pure headaches
Timoses
timosesu at gmail.com
Fri Jul 6 11:10:27 UTC 2018
I dared once again getting into immutable by adding an
"immutable" keyword which causes a chain of actions to be taken.
I feel like I'm lost in a jungle of immutable, inout and pure
(perhaps more will join the party...).
To start off, why does this not work?
class Test
{
private S s;
this(S t) { this.s = t; }
this(immutable S t) immutable { this.s = t; }
inout(Test) get() inout
{
// Error: none of the overloads of __ctor are
callable using a inout object, candidates are:
//onlineapp.d(10): onlineapp.Test.this(S t)
//onlineapp.d(11): onlineapp.Test.this(immutable(S) t)
return new inout Test(this.s);
}
}
struct S
{
int[] a;
}
void main()
{
immutable S s = immutable S([1,2,3]);
auto t = new immutable Test(s);
}
More information about the Digitalmars-d-learn
mailing list