immuable method address and export method address.
Igor Stepanov
wazar.leollone at yahoo.com
Sun May 5 12:34:27 PDT 2013
Hello, I've two simple questions:
1. I have a structure:
struct Foo
{
public int bar() const {return 0;}
public int bar() immutable {return 1;}
}
How can I get immutable bar address?
When I've wrote next code I've got a const bar address. Is it a
bug?
void main()
{
immutable Foo boo;
int delegate() immutable dg = &boo.bar;
}
Next question:
If I write туче code, it'll be builded successfully
void main()
{
foreach(cur; __traits(getOverloads, Foo, "bar"))
{
void* p = &cur;
writeln(cur); //prints a function pointer.
}
}
If I change protection of bar to export I've got a error:
struct Foo
{
export int bar() const {return 0;}
export int bar() immutable {return 1;}
}
void main()
{
foreach(cur; __traits(getOverloads, Foo, "bar"))
{
void* p = &cur; //Error: need 'this' to access member bar
writeln(cur);
}
}
How should it be?
More information about the Digitalmars-d
mailing list