A
alex.mizrahi
helo
i'm going to use pointers to member function with virtual inheritance
in following way:
struct base {
public:
typedef void (base::*fun_t)(void);
int i;
void call(fun_t f) {
(this->*f)();
}
};
class derived : virtual public base {
public:
int j;
};
class derived2 : public derived {
public:
void fun() {
std::cout<<"1";
}
void callcall() {
call(reinterpret_cast<fun_t>(fun));
}
};
it requires reinterpret_cast in MSVC7.1 (and produces warning in g++),
but works.
is it ok? (i mean it will work under MSVC7.1, and maybe later, not
abstract portability and stadard conformance).
are there situations when it will fail?
is there some better _lightweight_ approach? (not involving heavy stuff
like boost::function -- it's definitely nice, but it's too much..)
(i've read article http://www.codeproject.com/cpp/FastDelegate.asp ,
but i didn't understand details enough to understand if it will really
work always).
with best regards, Alex 'killer_storm' Mizrahi.
i'm going to use pointers to member function with virtual inheritance
in following way:
struct base {
public:
typedef void (base::*fun_t)(void);
int i;
void call(fun_t f) {
(this->*f)();
}
};
class derived : virtual public base {
public:
int j;
};
class derived2 : public derived {
public:
void fun() {
std::cout<<"1";
}
void callcall() {
call(reinterpret_cast<fun_t>(fun));
}
};
it requires reinterpret_cast in MSVC7.1 (and produces warning in g++),
but works.
is it ok? (i mean it will work under MSVC7.1, and maybe later, not
abstract portability and stadard conformance).
are there situations when it will fail?
is there some better _lightweight_ approach? (not involving heavy stuff
like boost::function -- it's definitely nice, but it's too much..)
(i've read article http://www.codeproject.com/cpp/FastDelegate.asp ,
but i didn't understand details enough to understand if it will really
work always).
with best regards, Alex 'killer_storm' Mizrahi.