是否有任何非侵入性的方式来报告调用哪个客户端函数。 我不想更改客户端代码。如果我可以在调用end时保持y-> hello1()语法,那么某些代码注入是可以的。
由于 ABHI
struct client{
void hello1() {cout <<"hi 1";}
void hello2() {cout <<"hi 2";}
};
struct proxy {
client *target;
client *operator->() const
{ return target; }
};
void f() {
client x ;
proxy y = { & x };
std::cout <<y->hello1(); //would like proxy to print "hell01 is called
std::cout <<y->hello2(); //would like proxy to print "hell02 is called
}