title: Casting void pointers, depending on data (C++)
body: <p>Basically what I want to do is, depending on the some variable, to cast a void pointer into a different datatype.  For example (the 'cast' variable is just something in order to get my point across):</p>
  
  <pre><code>void* ptr = some data;
  int temp = some data;
  int i = 0;
  
  ...
  
  if(temp == 32)      cast = (uint32*)
  else if(temp == 16) cast = (uint16*)
  else                cast = (uint8*)
  
  i = someArray[*((cast)ptr)];
  </code></pre>
  
  <p>Is there anything in C++ that can do something like this (since you can't actually assign a variable to be just (uint32*) or something similar)?  I apologize if this isn't clear, any help would be greatly appreciated.</p>