Changing name of function being called in a template
Hello all,
I have a feeling this may be off the topic of Boost, so if anyone can point
me in the direction of a better place to ask please do (a templates mailing
list?). However, I post it here because I think Boost::Bind does something
similar internally to what I want to do, so someone may be able to advise.
I have a couple of templated class which implement a simple observer pattern
(yes I know Boost has signals, but it's not thread safe).
It uses a virtual function to make a call in to the observer from the
subject. My own observer then derive from this class and implement the
notify function. However, I would like to 'template' the name of the
function, so that different instances of the template can make calls to
different named function.
Now in Boost:bind you specify the name of the function in the class to be
called, but I don't know how to implement that in my own template class.
class observer<typename T>
{
virtual void Notify(T&); // This is the function I want to rename
according to the template
}
so I might want, in a different instance, the Notify function to be called,
Shutdown(). Following code is NOT valid C++, but gives an idea of what I am
trying to implement, but don't know enough yet to do so!!
class observer
participants (1)
-
James Hughes