title: C++: boost ptree remove children: no matching function
body: <p>In an attempt to remove children of a boost property tree, I use a direct node in <code>erase</code> function which lead to </p>
  
  <pre><code>error: no matching function for call to 
  ‘boost::property_tree::basic_ptree&lt;std::__cxx11::basic_string&lt;char&gt;, 
  std::__cxx11::basic_string&lt;char&gt; &gt;::erase(std::pair&lt;const 
  std::__cxx11::basic_string&lt;char&gt;, 
  boost::property_tree::basic_ptree&lt;std::__cxx11::basic_string&lt;char&gt;, 
  std::__cxx11::basic_string&lt;char&gt; &gt; &gt;&amp;)’
  </code></pre>
  
  <p>at</p>
  
  <pre><code>pt0.erase(pt_child);
  </code></pre>
  
  <p>What is the correct form of the code?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/property_tree/ptree.hpp&gt;
  #include &lt;boost/property_tree/json_parser.hpp&gt;
  
  using namespace boost::property_tree;
  
  void print(const ptree &amp;p)
  {
      json_parser::write_json(std::cout, p);
  }
  
  int main()
  {
      ptree pt0;
  
      for(int i=0;i&lt;10;i++)
          pt0.put_child("kid"+std::to_string(i+1),ptree());
      print(pt0);
  
      for(auto&amp; pt_child : pt0)
          pt0.erase(pt_child);
      print(pt0);
  
      return 0;
  }
  </code></pre>