title: C++ : Ignoring multiple << Operators in a line
body: <p>Say I have the following code:</p>
  
  <pre><code>int ignored = 0;
  StreamIgnore si;
  
  si &lt;&lt; "This part" &lt;&lt; " should be" &lt;&lt; ignored &lt;&lt; std::endl;
  </code></pre>
  
  <p>I want that when this code runs <code>si</code> will simply ignore the rest of the stream.
  The thing is I want this to be as efficient as possible.
  One obvious solution would be to have:</p>
  
  <pre><code>template &lt;typename T&gt;
  StreamIgnore&amp; opertaor&lt;&lt;(const T&amp; val) {
      //Do nothing
      return *this;
  }
  </code></pre>
  
  <p>BUT, if the code was something like:</p>
  
  <pre><code>StreamIgnore si;
  
  si &lt;&lt; "Fibonacci(100) = " &lt;&lt; fib(100) &lt;&lt; std::endl;
  </code></pre>
  
  <p>Then I'll have to calculate <code>fib(100)</code> before the <code>//Do Nothing</code> part.
  So, I want to be able to ignore the rest completely without any unnecessary computations.</p>
  
  <p>To make this request make sense, think that <code>StreamIgnore</code> could be a <code>StreamIgnoreOrNot</code> class, and the c'tor decides whether to ignore the stream or not by either returning <code>*this</code> and use the stream, or a <code>new StreamIgnore()</code> instance and ignoring the rest.</p>
  
  <p>I thought about using Macros some how but could't come up with something that enables me to use this syntax (i.e <code>"si &lt;&lt; X &lt;&lt; Y..."</code>).</p>
  
  <p>I would appreciate it if someone could suggest a way to do that.</p>
  
  <p>Thanks </p>