I have read through the documentation for boost::property_tree and have not found a way to update or merge a ptree with another ptree. How do I do this?
Given the code below, how would the update_ptree function look like?
#include <iostream>
#include <boost/property_tree/ptree.hpp>
using boost::property_tree::ptree;
class A
{
  ptree pt_;
public:
  void set_ptree(const ptree &pt)
  {
    pt_ = pt;
  };
  void update_ptree(const ptree &pt)
  {
    //How do I merge/update a ptree?
  };
  ptree get_ptree()
  {
    return pt_;
  };
};
int main()
{
  A a;
  ptree pt;
  pt.put<int>("first.number",0);
  pt.put<int>("second.number",1);
  pt.put<int>("third.number",2);
  a.set_ptree(pt);
  ptree pta = a.get_ptree();
  //prints "0 1 2"
  std::cout << pta.get<int>("first.number") << " "
            << pta.get<int>("second.number") << " "
            << pta.get<int>("third.number") << "\n";
  ptree updates;
  updates.put<int>("first.number",7);
  a.update_ptree(updates);
  pta = a.get_ptree();
  //Because the update_tree function doesn't do anything it just prints "0 1 2".
  //I would like to see "7 1 2"
  std::cout << pta.get<int>("first.number") << " " 
            << pta.get<int>("second.number") << " " 
            << pta.get<int>("third.number") << "\n";
  return 0;
}
I have thought about iterating over the new ptree and using "put" to insert values. But "put" requires a type and I don't know how to get that information from the new ptree and use it as a argument for the old ptree.
One thing I have tried in the update_ptree function is using:
pt_.add_child(".",pt);
Basically I try to add the pt as a child to the root of pt_. Unfortunately this does not seem to work.
Any ideas?
I am grateful for any help.
Thank you.
(I tried to add the tags property_tree and ptree to this question but I wasn't allowed to)