title: boost::signal with arguments from static member function?
body: <p>rtmidi library requires setting callback to static function, which should handle incoming midi messages. I found workaround (CinderMidiIn::callback function) but application crashes when I try to send signal after parsing. Here is shortened version of code:</p>
  
  <pre><code>void static callback(double deltatime, std::vector&lt; unsigned char &gt; *message, void *userData){
      ((CinderMidiIn*)userData)-&gt;newMidiMessage(deltatime * 1000, message);
  }
  void newMidiMessage(double deltatime, std::vector&lt; unsigned char &gt; *message){
  
      midiMessage newMsg(message);
  
                      //parse message
  
      //midiSignal(newMsg); /// THIS DOES NEITHER WORKS
      dispatch(newMsg);
  }
  
  void dispatch(midiMessage &amp;msg){
  
      midiSignal(msg);
  }
  
  // Signal
  boost::signals2::signal&lt;void(midiMessage)&gt; midiSignal;
  
  
  //// MAIN FUNCTION    ////
  
  void ciMidiIn::midiEvent(midiMessage msg){
  cout &lt;&lt; "value " &lt;&lt; msg.value &lt;&lt; endl;
  }
  
  void ciMidiIn::setup()
  {
  midi.midiSignal.connect(boost::bind(&amp;ciMidiIn::midiEvent, this, boost::arg&lt;1&gt;::arg()));
  }
  </code></pre>
  
  <p>I get a ton of warning during compilation and crashes on start (at sending signal at line 149-150) call-stack gives me no clue even where to start looking for solution:</p>
  
  <pre><code> VanillaRTMidi.exe!boost::signals2::signal1&lt;void,midiMessage,boost::signals2::optional_last_value&lt;void&gt;,int,std::less&lt;int&gt;,boost::function&lt;void __cdecl(midiMessage)&gt;,boost::function&lt;void __cdecl(boost::signals2::connection const &amp;,midiMessage)&gt;,boost::signals2::mutex&gt;::operator()(midiMessage arg1) Line 695 C++
  VanillaRTMidi.exe!boost::shared_ptr&lt;boost::signals2::detail::signal1_impl&lt;void,midiMessage,boost::signals2::optional_last_value&lt;void&gt;,int,std::less&lt;int&gt;,boost::function&lt;void __cdecl(midiMessage)&gt;,boost::function&lt;void __cdecl(boost::signals2::connection const &amp;,midiMessage)&gt;,boost::signals2::mutex&gt; &gt;::operator*() Line 646 C++
  </code></pre>
  
  <p>I've read a lot about static functions and I understand that non static variables cannot access static function, but still, I have no idea how to pass anything into signal and dispatch it from static function.</p>
  
  <p><strong>Disclaimer:</strong> <a href="https://forum.libcinder.org/topic/using-signals-from-static-function-causing-crash" rel="nofollow">Originally posted on Cinder Forums</a>, with link to pastebin containing full code, but as I mentioned at top of original post, this is more likely question for Stack Overflow. </p>