It turns out it's quite hard to have @safe pure nothrow functions. Oh, and const.
Kagamin via Digitalmars-d
digitalmars-d at puremagic.com
Sat Sep 13 09:44:24 PDT 2014
On Saturday, 13 September 2014 at 01:37:59 UTC, Jakob Ovrum wrote:
> Now try calling it: http://dpaste.dzfl.pl/bbd02a4d61df
That way it shouldn't work as it would break the type system,
that code is equivalent to:
struct S
{
int* p;
inout(int)* foo() inout { return p; } // OK
void bar(void delegate(const int*) dg) const {
dg(p);
}
}
void main()
{
import std.stdio;
S s;
writeln(s.foo());
immutable(S) s2;
s2.bar((const int* p) => writeln(p));
s.bar((const int* p) => writeln(p));
}
Is there a reason, why you would need inout there?
More information about the Digitalmars-d
mailing list