title: Don't know template parameter types when casting a void* to a templated type
body: <p>I am using the pthreads library and when I create a thread I am giving it the pointer to an object that is a templated type.</p>
  
  <p>I'm inexperienced with templates (just read about them today) and need to cast the void* parameter from the method declaration the pthread runs to the templated type so I can access its members. In short something that looks like so:</p>
  
  <p>In short something like this:</p>
  
  <pre><code>template &lt;typename T&gt;
  class A {
      ...
      ...
      ...
      void aMember() { ... }
  };
  
  int main() {
      A&lt;int&gt; a;
  
      pthread_create(..., ..., &amp;run, &amp;a);
  
      ...
      ...
      ...
  }
  
  void *run(void *arg) {
      (A*)arg-&gt;aMember()
  }
  </code></pre>
  
  <p>My problem is I get all these errors that I don't know how to rectify. I do in fact understand the errors but don't know the solution. Here are the errors:</p>
  
  <p>error: expected primary-expression before ( token
  error: missing template arguments before * token
  error: expected primary-expression before ) token
  error: expected `)' before 'info'</p>
  
  <p>I just don't see how I could ever know the argument types of A when I am casting to it once in the thread?</p>
  
  <p>I'm using the C++ Templates: The Complete Guide book as a reference/learning resource and must say I am over whelmed with all the info needed to fully understand templates. I was wondering if anyone had a solution to the problem, or could point me in the direction of another resource that might provide answers.</p>
  
  <p>As always I appreciate your help greatly.</p>
  
  <p><strong>EDIT/UPDATE</strong></p>
  
  <p>It seems that adding context to my problem might help. Alternatively maybe someone can provide a different solution using a different design.</p>
  
  <p>I am using libcurl to make HTTP Requests and depending on the Response I receive I will create an object of a specific type (thus the templates). I create a new thread for each Request I would like to make so that everything runs Asynchronously. </p>