title: Storing variadic parameter and callback for later usage
body: <p>I want to create a simple but generic callback with variadic parameters. I also need storing them, because callback will called later in time (from a different thread which uses the storage).</p>
  <p>Here's what I have until now:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  void fileMgr_DoneWithOtherstuff_DoTheReads() {
    FROM SOMESTORAGE get the callback and params
    Do the reading
    string result = &quot;CONTENT&quot;;
    Call the callback with result string and params
  }
  
  template&lt;class ReadFileCallback, class ...T&gt;
  void fileMgr_ReadWithCallback(string filename, ReadFileCallback callback, T ...params) {
      cout &lt;&lt; &quot;fileMgr_ReadWithCallback is processing file: &quot; &lt;&lt; filename &lt;&lt; endl;
  //        string content = &quot;CONTENT&quot;;
  //        callback(content, params...);
  
        SOMESTORAGE = callback + params;
  }
  
  
  void readFileResult(string contents, int id) {
      cout &lt;&lt; &quot;readFileResult callback: contents=&quot; &lt;&lt; contents &lt;&lt; &quot;, id=&quot; &lt;&lt; id &lt;&lt; endl;
  }
  
  void readFile(string filename, int id) {
      fileMgr_ReadWithCallback(filename, readFileResult, id);
  }
  
  int main()
  {
      int fileId = 1;
      readFile(&quot;myfile&quot;, fileId);
      
      return 0;
  }
  </code></pre>
  <p>But I don't want to call callback in <code>fileMgr_ReadWithCallback</code>, because it should be an async method, so I'd rather store the callback function and its parameters, and use it later once File Manager is able to perform the operation.</p>
  <p>So the question is, what's the way to store <code>ReadFileCallback</code> and <code>...T</code> into a struct maybe?</p>
  <p>Or if there is better way doing this, let me know please.</p>
  <p>I need the variadic arguments, as sometimes the extra param is just an int, but sometimes it can be 2 ints, or 1 string, etc, and I want to keep the FileManager generic.</p>
  <p>I'm limited to C++11, but Boost is available.</p>