title: C++ Protobufs :: How to erase particular field with MergeFrom()?
body: <p>First of all: I'm not an expert in protobuf.</p>
  
  <p>Suppose I have such message structure:</p>
  
  <pre><code>package msg_RepAndOpt;
  
  message RepAndOpt
  {
      repeated string name = 1;
      optional string surname = 2;
      ...
      // there are lots of others.
  }
  </code></pre>
  
  <p>And I have two components that have copies of this message:</p>
  
  <pre><code>// component1:
  RepAndOpt A;
  A.add_name("Name");
  A.set_surname("Surname");
  
  // component2:
  RepAndOpt B;
  </code></pre>
  
  <p>In my case components modify those messages via transaction mechanism. It means that if one component changes some field it also sends it to another component to propagate those changes. Component-receiver is doing merge:</p>
  
  <pre><code>// Component2 modifies B and sends it to component1.
  // Component1 perfoms merge:
  A.MergeFrom(B);
  </code></pre>
  
  <p>Now, say, component2 wants to erase field "name".
  If it will send clear B message (default construction) than:</p>
  
  <ul>
  <li>MergeFrom() will not modify A;</li>
  <li>CopyFrom() will erase also other fields.</li>
  </ul>
  
  <p>Another way will be to fill B with the contents of A, clear name field and component1 will use CopyFrom().
  But this is not acceptable because system is really high-loaded and there could be lots of other fields. 
  So, desired solution to clean name field is: </p>
  
  <ol>
  <li>Component2 create B message. </li>
  <li>Explicitly stores information that it want to erase only name field.</li>
  <li>Component1 perform A.MergeFrom(B).</li>
  <li>Result: A::name is cleared but other fields are left untouched.</li>
  </ol>
  
  <p>As far as I tested this applies to repeated and optional fields.
  Is there any ready-to-use solution or I should modify protobuf implementation?</p>