title: How to break a for loop in Ternary Operator
body: <p>So, a method would be to <code>cout&lt;&lt;"";</code> if the condition is false but I don't feel like it's the right way and <code>break</code> doesn't seem to work. Is there something I should know ?</p>
  
  <pre><code>template &lt;class T&gt;
  T get(const string &amp;prompt) {
      cout&lt;&lt;prompt;
      T ret;
      cin&gt;&gt;ret;
      return ret;
  }
     int main()
  {
      vector&lt;int&gt;x;
          for(int i=0;i&lt;1000;i++) x.push_back((rand()%1200+1200));
      int rating=get&lt;int&gt;("Your rating: ");x.push_back(rating);
          sortVector(x);
      for(int i=0;i&lt;x.size();i++) ((x[i]==rating) ? cout&lt;&lt;"Found your rating on pozition "&lt;&lt;i : cout&lt;&lt;"");
  }
  </code></pre>