title: Why can't C++ set iterators be cast to bool?
body: <p>For an STL set (s), it seems like you should be able to say:</p>
  
  <pre><code>if(s.find(x)) {
      //Something
  }
  </code></pre>
  
  <p>as opposed to</p>
  
  <pre><code>if(s.find(x) != s.end()) {
      //Something
  }
  </code></pre>
  
  <p>Furthermore, if set-iterators could be cast to bool (true if the internal pointer is not null), you would be able to.  Why don't STL set iterators have this simple functionality?  Was this intentionally left out?</p>
  
  <p>CLARIFICATION:</p>
  
  <p>Alternatively, set's could just have a set::contains(x) method which returns a bool directly, but this doesn't seem to be implemented either.  I know it's only a couple characters, but in the case where s is a return value from some function, this can be frustrating because of the need to create a temporary variable, ie (supposing m is of type <code>map&lt;int,set&lt;int&gt;&gt;</code>)</p>
  
  <pre><code>const set&lt;int&gt;&amp; s = m[i];
  return s.find(x) != s.end();
  </code></pre>
  
  <p>as opposed to</p>
  
  <pre><code>return m[i].contains(x);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>return m[i].find(x);
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>I didn't realize the count() method could be used as contains().  Voted to close since this question doesn't properly phrase what I really should have asked: Do STL::set's have a "contains" method?</p>