[Issue 13623] New: std.typecons.Proxy doesn't work inside classes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Oct 16 15:37:31 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13623
Issue ID: 13623
Summary: std.typecons.Proxy doesn't work inside classes
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: nobody at puremagic.com
Reporter: code at dawg.eu
cat > bug.d << CODE
import std.typecons, std.traits;
class Foo
{
private int value;
mixin Proxy!value;
this(int n){ value = n; }
}
unittest
{
auto a = new Foo(10), b = new Foo(10);
assert(a == b); // Proxy should override Object.opEquals
a = 13;
}
CODE
dmd -unittest -main -run bug
----
I think it's reasonable for Proxy to only work inside structs, but there should
be a check in the mixin template.
static assert(!is(typeof(this) == class), "Proxy cannot be used inside
classes.");
--
More information about the Digitalmars-d-bugs
mailing list