Home » Extra libraries, Code snippets, applications etc. » C++ language problems and code snippets » THISBACK and function-overloading
Re: THISBACK and function-overloading [message #17025 is a reply to message #17024] |
Fri, 25 July 2008 11:49  |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
I've had this problem, these are two solutions that I know of:
1) Obvious. Resolve the ambiguity by naming one of you functions something else.
2) Resolve the ambiguity caused by the compiler not being able to determine which version of the callback function to use. You could do this by casting the function pointer correctly, but this would be very ugly.
My prefered solution is to define callback0 somewhere (it's identical to callback, except for the name):
template <class OBJECT, class METHOD>
Callback callback0(OBJECT *object, void (METHOD::*method)()) {
return callback(object, method);
}
template <class OBJECT, class METHOD>
Callback callback0(const OBJECT *object, void (METHOD::*method)() const) {
return callback(object, method);
}
inline Callback callback0(void (*fn)()) {
return callback(fn);
}
#define THISBACK0(x) callback0(this, &CLASSNAME::x) And then it is available to use for resolving this sort of ambiguity.
Perhaps there is a better solution available that I haven't thought of?
[Updated on: Fri, 25 July 2008 11:55] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Mon Aug 18 23:57:00 CEST 2025
Total time taken to generate the page: 0.07141 seconds
|