title: How is std::cin >> std::string implemented?
body: <p>In particular, how do the code check if memory for chars should be reallocated? Or how many chars the user entered?
  If I wanted to assign a C-string's value to my implementation of a string class I would probably do something like this</p>
  
  <pre><code>   String&amp; operator=(String&amp; to, const char *from)
     {
        if((strlen(from) + 1) &gt; to.size) {
          if (to.str != NULL) {
            delete[] to.str;
            to.str = NULL;
          }
          to.size = strlen(from) + 1;
          to.str = new char[to.size];
        }
        strcpy(to.str, from);
        return to;
      }
  </code></pre>
  
  <p>Easy enough. But the operator>> of the std::string is really making me curious.</p>