title: Get a std::function into a new thread created by a c-api i.e. windows scm
body: <h2>Background (To hopefully avoid a XY-Question:)</h2>
  
  <p>To refactor my C++ code handling the windows service manager, I'm trying to write a portable c++ service library including windows service manager.</p>
  
  <p>So I thought the most comfortable, but simple approach would offer the user, to deliver his/her root functions, which reassembles the actual service, as a <code>std::function&lt;void(void)&gt;</code>, thus additional user defined parameters could be added via lambdas or <code>std::bind</code>.</p>
  
  <h2>Precondition</h2>
  
  <p>These user defined functions, will often have to start in new threads (like in the windows scm).</p>
  
  <p><strong>Problem is:</strong> old C-APIs like many service frameworks, i.e. the windows service framework, makes it impossible to pass the function of the new thread any arguments. (yes often <code>*void</code> is allowed but would AFAIK imply lifetime problems and the windows framework doesn't allow even that.)</p>
  
  <h2>Question</h2>
  
  <p>So how do I get this <code>std::function</code>(s) into a new thread(s), without using passed arguments?</p>
  
  <p>I thought of maybe using a static <code>std::map&lt;id,std::function&lt;&gt;&gt;</code> but I don't know what to use as the id.</p>