Non-Purity of Algebraic opEquals
Nordlöw via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 18 06:53:46 PDT 2015
On Friday, 18 September 2015 at 13:22:14 UTC, Nordlöw wrote:
> Ideas anyone?
I tried tagging up `VariantN` with pure until I got to
@property inout(T)* peek(T)() inout pure
{
static if (!is(T == void))
static assert(allowed!(T), "Cannot store a " ~
T.stringof
~ " in a " ~ VariantN.stringof);
if (type != typeid(T))
return null;
static if (T.sizeof <= size)
return cast(inout T*)&store;
else
return *cast(inout T**)&store;
}
which then errors as
variant.d(701,13): Error: pure function
'std.variant.VariantN!32LU.VariantN.peek!void.peek' cannot call
impure function 'object.opEquals'
for the line
if (type != typeid(T))
Why is `object.opEquals` not pure?
More information about the Digitalmars-d
mailing list