title: most efficient way to convert char vector to string
body: <p>I have these large pcap files of market tick data. On average they are 20gb each. The files are divided into packets. Packets are divided into a header and messages. Messages are divided into a header and fields. Fields are divided into a field code and field value. </p>
  
  <p>I am reading the file a character at a time. I have a file reader class that reads the characters and passes the characters by const ref to 4 call back functions, on_packet_delimiter, on_header_char, on_message_delimiter, on_message_char. The message object uses a similar function to construct its fields.</p>
  
  <p>Up to here I've noticed little loss of efficiency as compared to just reading the chars and not doing anything with them. </p>
  
  <p>The part of my code, where I'm processing the message header and extracting the instrument symbol of the message, slows down the process considerable. </p>
  
  <pre><code>void message::add_char(const char&amp; c)
  {
    if (!message_header_complete) {
      if (is_first_char) {
        is_first_char = false;
        if (is_lower_case(c)) {
          first_prefix = c;
        } else {
          symbol_vector.push_back(c);
        }
      } else if (is_field_delimiter(c)) {
        on_message_header_complete();
        on_field_delimiter(c);
      } else {
        symbol_vector.push_back(c);
      }
    } else {
      // header complete, collect field information
      if (is_field_delimiter(c)) {
        on_field_delimiter(c);
      } else {
        fp-&gt;add_char(c);
      }
    }
  }
  
  ...
  
  void message::on_message_header_complete()
  {
    message_header_complete =  true;
    symbol.assign(symbol_vector.begin(),symbol_vector.end());
  }
  
  ...
  </code></pre>
  
  <p>In <code>on_message_header_complete()</code> I am feeding the chars to <code>symbol_vector</code>. Once header is complete I convert to string using vector iterator. Is this the most efficient way to do this? </p>