title: Access field from string?
body: <p>Given a string:</p>
  
  <pre><code>std::string foo = "world-&gt;units.all[0]";
  </code></pre>
  
  <p>How can I pass the value that <code>foo</code> represents to a function? :</p>
  
  <pre><code>bar(foo);        // Passing the string
  bar(magic(foo)); // Passing world-&gt;units.all[0] (whatever that is)
  </code></pre>
  
  <p>Note: The string <code>foo</code> is user input, however I'm not going to worry about users blowing themselves up since it's all local. The structures being accessed are structs, classes, arrays and pointers.</p>