title: how to declare variable using typeinfo.name C++
body: <p>I love coding, and generally do so in Python due to its simplicity and power.<br>
  However, for some time critical programs/tasks, I use C++.<br>
  Therefore, to get best of both worlds, I am making a Pythonesque list in C++.  </p>
  
  <p><em>AIM:</em> I would like to be able to add any variable or value of any data type, <strong>including classes user has defined</strong>.<br>
  To do this, I have a structure <code>item</code> with a <code>char * value</code>, a <code>char * type</code> and an <code>int size</code>.<br>
  My <code>List</code> has an array of these <code>item *</code> s.</p>
  
  <hr>
  
  <p>Now, I have taken the variable in a template function:<br>
  <code>template&lt;class T&gt; item * encode(const T&amp; var);</code><br>
  and declared a pointer to item <code>item * i = new item;</code>  </p>
  
  <p>And, I have stored the values of these variables as c style strings.<br>
  For example, <code>14675</code> in binary is <code>0000 0000 0000 0000 0011 1001 0101 0011</code><br>
  Therefore, I have dynamically created space, like so:<br>
  <code>i-&gt;size = sizeof(var);</code><br>
  <code>i-&gt;value = new char[i-&gt;size];     //4 in this case</code><br>
   and set each bit in value with respective bits in var.  </p>
  
  <p>I have also stored their types as<br>
  <code>i-&gt;type = typeinfo(var).name();</code><br>
  So far so good!</p>
  
  <hr>
  
  <p>Now, I am stuck with <code>auto decode(item * i) -&gt; decltype(/*What goes here???*/)</code><br>
  How do I specify the return type of the function?<br>
  Is there any possible way?<br>
  Preferably using the <code>i-&gt;type</code>?<br>
  Or, should I make changes in the basic design of this process?<br>
  Thanks in advance!</p>