[Issue 2811] New: mixin fields not visible inside mixin method
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 6 08:42:33 PDT 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2811
Summary: mixin fields not visible inside mixin method
Product: D
Version: 2.027
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: 2korden at gmail.com
Let's start with code I'd like to write:
struct Own(T)
{
void opAssign(ref Own other)
{
_ptr = other._ptr;
other._ptr = null;
}
private T _ptr = null;
}
I'm trying to use it like this:
alias Own!(Resource) ResourcePtr;
but it causes template forward referencing all the time.
So my next step is to workaround this issue:
class Resource {}
struct OwnT(T, Own)
{
void opAssign(ref Own other)
{
_ptr = other._ptr;
other._ptr = null;
}
protected T _ptr = null;
}
struct ResourcePtr
{
mixin OwnT!(Resource, ResourcePtr);
}
But I'm getting the following errors:
test.d(7): Error: no property '_ptr' for type 'ResourcePtr'
test.d(7): Error: cannot implicitly convert expression (1) of type int to
test.Resource
test.d(7): Error: cannot cast int to test.Resource
test.d(8): Error: no property '_ptr' for type 'ResourcePtr'
test.d(8): Error: constant other._ptr is not an lvalue
test.d(8): Error: cannot implicitly convert expression (null) of type void* to
int
--
More information about the Digitalmars-d-bugs
mailing list