title: Boost: How to get a subtree form an existing property tree?
body: <p>I am trying to get a subtree from a <code>boost::ptree</code> using <code>get_child</code> like this:</p>
  
  <p>I have:</p>
  
  <pre><code>class ConfigFile
  {
    ptree pt;
    ConfigFile(const string&amp; name)
    {
      read_json(name, pt);
    }
    ptree&amp; getSubTree(const string&amp; path)
    {
      ptree spt = pt.get_child(path);
      return spt;
    }
  }
  </code></pre>
  
  <p>and when I call </p>
  
  <pre><code>ConfigFile cf("myfile.json");
  ptree pt = cf.getSubTree("path.to.child")
  </code></pre>
  
  <p>the function crashes after return saying</p>
  
  <pre><code>terminate called after throwing an instance of 'std::length_error'
  </code></pre>
  
  <p>Can someone help me with this? what am I doing wrong?</p>