title: c++ heterogeneous map with arrays
body: <p>I have seen people suggest using boost::any to have a heterogeneous map. I.e. </p>
  
  <pre><code>map&lt;string,boost::any&gt; 
  </code></pre>
  
  <p>Has anyone had any luck storing (and successfully using ) arrays stored in the map doing said technique? </p>
  
  <p>I have been able to do the following:</p>
  
  <pre><code>boost::array&lt;char,100&gt; myArr;
  map&lt;string,boost::any&gt; myMap;
  myArr[51] = a; 
  myMap["imageData"] = myArr;
  </code></pre>
  
  <p>The problem with this is that this seems to store the entire array in memory twice.
  If I change it up a bit and do this:</p>
  
  <pre><code>boost::array&lt;char,100&gt; myArr;
  map&lt;string,boost::any&gt; myMap;
  myArr[51] = a; 
  myMap["imageData"] = &amp;myArr;
  </code></pre>
  
  <p>I have no idea how to get the data back out of the map. How can I create a <code>boost::array&lt;char,100&gt;</code> pointer? Can I? Has anyone else been able to do something similar or has any ideas to do something similar in a more elegant way? </p>
  
  <p>Originally, I wanted to store a <code>char[100]</code> into the map but I could find no way to cast it once in the map (In order to use the data in the map, one must cast it to the proper type). A solution that would allow me to get a <code>char[someSize]</code> out of the map would be ideal. </p>