title: Handling std::function with SWIG
body: <p>Apparently, SWIG does not understand <code>std::function</code> and breaks Python bindings. For instance, this works in C++:</p>
  
  <pre><code>// Somewhere in the API
  typedef std::function&lt;void(const UnitError &amp; error)&gt; UnitErrorHandler;
  
  // Somewhere else in the API
  void Unit::setErrorHandler(const UnitErrorHandler &amp; handler) {}
  
  // In the application code
  unit-&gt;setErrorHandler([](const UnitError &amp; error){
      std::cerr &lt;&lt; error &lt;&lt; std::endl;
      std::exit(1);
  });
  </code></pre>
  
  <p>But this will break code (apart from having a different behaviour for the sake of simplicity, but that's not the point):</p>
  
  <pre><code>unit.setErrorHandler(lambda error: len(error))
  </code></pre>
  
  <p>The situation is the same with <code>def</code> (ordinary) unbound functions.
  So, does anyone know a workaround for this?</p>