title: Does an empty string contain an empty string in C++?
body: <p>Just had an interesting argument in the comment to one of my questions. My opponent claims that the statement <code>""</code> does <strong>not</strong> contain <code>""</code> is wrong. </p>
  
  <p>My reasoning is that if <code>""</code> contained another <code>""</code>, that one would also contain <code>""</code> and so on.</p>
  
  <p>Who is wrong?</p>
  
  <p>P.S.</p>
  
  <p>I am talking about a <code>std::string</code></p>
  
  <p>P.S.  P.S</p>
  
  <p>I was not talking about substrings, but even if I add to my question " as a substring", it still makes no sense. An empty substring is <strong>nonsense</strong>. If you allow empty substrings to be contained in strings, that means you have an infinity of empty substrings. What is the point of that?</p>
  
  <h2>Edit:</h2>
  
  <p>Am I the only one that thinks there's something wrong with the function <code>std::string::find</code>?</p>
  
  <p>C++ reference clearly says </p>
  
  <blockquote>
    <p>Return Value: The position of the first character of the first match.</p>
  </blockquote>
  
  <p>Ok, let's assume it makes sense for a minute and run this code:</p>
  
  <pre><code>string empty1 = "";
  string empty2 = "";
  
  int postition = empty1.find(empty2);
  
  cout &lt;&lt; "found \"\" at index " &lt;&lt; position &lt;&lt; endl;
  </code></pre>
  
  <p>The output is: <code>found "" at index 0</code></p>
  
  <p><strong>Nonsense part</strong>: how can there be index 0 in a string of length 0? It is nonsense.</p>
  
  <p>To be able to even <strong>have</strong> a 0th position, the string must be at least 1 character long.</p>
  
  <p>And C++ is giving a exception in this case, which proves my point:</p>
  
  <pre><code>cout &lt;&lt; empty2.at( empty1.find(empty2) ) &lt;&lt; endl;
  </code></pre>
  
  <p>If it really contained an empty string it would had no problem printing it out. </p>