[Issue 10237] New: std.typecons.Proxy doesn't work with @property
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Jun 2 02:33:22 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10237
Summary: std.typecons.Proxy doesn't work with @property
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: zan77137 at nifty.com
--- Comment #0 from SHOO <zan77137 at nifty.com> 2013-06-02 02:33:19 PDT ---
This code doesn't work:
import std.typecons;
struct A(T)
{
private:
T* _p;
ref inout(T) _instance() inout { return *cast(inout(T)*)_p; }
ref immutable(T) _instance() immutable { return *cast(immutable(T)*)_p; }
ref shared(T) _instance() shared { return *cast(shared(T)*)_p; }
ref const(shared(T)) _instance() const shared { return
*cast(const(shared(T))*)_p; }
public:
mixin Proxy!(_instance);
}
struct B(T)
{
private:
T* _p;
@property ref inout(T) _instance() inout { return *cast(inout(T)*)_p; }
@property ref immutable(T) _instance() immutable { return
*cast(immutable(T)*)_p; }
@property ref shared(T) _instance() shared { return *cast(shared(T)*)_p; }
@property ref const(shared(T)) _instance() const shared { return
*cast(const(shared(T))*)_p; }
public:
mixin Proxy!(_instance);
}
void main()
{
static struct Foo { @property int foo(){return 0;} }
alias A!Foo AFoo;
AFoo af;
af._p = new Foo;
assert(af.foo == 0); // NG
alias B!Foo BFoo; // NG
BFoo bf;
bf._p = new Foo;
assert(bf.foo == 0);
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list