I was wondering if is possible get pointer that points a method pointer of a class, i've tried something like this, consider this:
class x {
public:
int a;
int GetSomeVal(int b) {
return b * 4;
}
};
class y {
public:
int ha;
int (*HGetSomeVal)(int); // pointer method
};
// y::HGetSomeVal now points to x::GetSomeVal
int(y::*HGetSomeVal)(int) = (int(y::*)(int))&x::GetSomeVal;
Used in this context:
int main() {
x a;
y* b;
b = (y*)&a; // pointer of x to y
std::function<int(int)> NewFunc;
std::function<int(int)> OtherNewFunc;
NewFunc = std::bind1st(std::mem_fun(&x::GetSomeVal), b); // works!
OtherNewFunc = std::bind1st(std::mem_func(&y::*HGetSomeVal), b); // not get the pointer, i want get the pointer that points to x::GetSomeVal through of y::HGetSomeVal.
// print testing pointers
printf("%p | %p", &x::GetSomeVal, &y::*HGetSomeVal);
// Pointer A: 00421e00 SUCESS, Pointer B: 000000 NOT GET POINTER.
return 0;
}
Duplicate edit: this isn't duplicated, i've followed Function pointer to member function
and isn't same i'm using a class pointer, then i've done something like this:
OtherNewFunc = std::bind1st(std::mem_func((y->*(y->HGetSomeVal)), b);
printf("Pointer A: %p | \n", (y->*(y->HGetSomeVal)));
then i'm getting the next error:
internal compiler error: in gimplify_expr, at gimplify.c:8343
How i can get the value of pointer that points HGetSomeVal?