[sigc] question on implementation



In the interest of learning, I have a question regarding libsigc++
that I would appreciate if you could answer when (if?) you get a spare
moment.

For a class project I needed some way of being able to store and call
callback functions to class member functions without using static
class function stubs and void pointers. I developed a simple system
using an abstract Functor(N) base class with concrete FunctorPF(N) and
FunctorMF(N) classes wrapped in a Callback class. The two concrete
Functor classes know how to make callbacks to regular function
pointers and member function pointers. The Callback class holds a
pointer to the base class and makes a virtual function call to execute
the proper callback.

I then stumbled on libsigc++ and was curious about your
implementation. There seems to be some sort of template or
reinterpret_cast magic going on that I don't yet understand. I'm
curious how in libsigc++ a signal maintains a list of base classes,
and yet calls the proper function without making a virtual function
call. If you have a moment to give me a quick explanation, I would
appreciate it!

Thanks,

Nick



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]