title: C++ YAML: How to edit/write to a node in a .yaml file
body: <p>I am trying to write a function that will write/edit a node in my <code>.yaml</code> file using <code>yaml-cpp</code>. I kind of got it working as my code will edit the local copy. When I print out <code>_baseNode</code> it shows that the node has the value 5.4 in it. However, after exiting the function and checking my <code>.yaml</code> on my computer the value 5.4 is not there.</p>
  
  <p>Here is my attempt (<code>_baseNode</code> is a private member of my class):</p>
  
  <pre><code>void ParametersServerPC::testFunc2() {
  
      boost::filesystem::path path(boost::filesystem::initial_path() / _parameterFileName);
      _baseNode = YAML::LoadFile(_parameterFileName);
  
      _baseNode["chip"]["clock_rate"]["3"] = 5.4;
  
      std::cout &lt;&lt; _baseNode &lt;&lt; std::endl;
  
  }
  </code></pre>
  
  <p>For my second attempt, I created a <code>YAML::Node&amp; baseNode</code>:</p>
  
  <pre><code>YAML::Node&amp; baseNode = YAML::LoadFile(_parameterFileName);
  </code></pre>
  
  <p>but then I get this error:</p>
  
  <pre><code>invalid initialization of non-const reference of type 'YAML::Node&amp;' from an rvalue of type 'YAML::Node'
  </code></pre>
  
  <p>For those who are interested, the <code>.yaml</code> file looks like this:</p>
  
  <pre><code>chip:
    clock_rate:
      0: 1.0
      1: 1.0
      2: 1.0
      3: 3.0
      4: 1.0
  </code></pre>
  
  <p>I want to change the value mapped by <code>3</code> from 3.0 to 5.4.</p>