title: Cleanest way to do callbacks in C++ without C++11?
body: <p>What is the cleanest way to do callbacks to a class in C++?</p>
  
  <p>I usually create a function like:</p>
  
  <pre><code>void registerCallback(void(*callback)(void* param), void* param);
  </code></pre>
  
  <p>And then call it like such:</p>
  
  <pre><code>foo-&gt;registerCallback(callbackStatic, this);
  </code></pre>
  
  <p>Then I add a static function in my class like such:</p>
  
  <pre><code>static void callbackStatic(void* param)
  {
      ((Type*)(param))-&gt;callback();
  }
  </code></pre>
  
  <p>It works, but it's a pain. I have to create two functions per callback. If I could use C++11, I'd use a lambda instead. Qt has a very nice signal and slot mechanism, but requires a special pre-compiler.</p>
  
  <p>I'm writing a library, so I'd like to keep the requirements as low as possible. No C++11, no boost, etc. Is there a way to build a lambda or signal/slot 'like' callback system only using C++03?</p>