title: C++ error when using stream buffers directly with ?: operator
body: <p>When I try to use a ternary conditional operator (?:) with stream buffer redirection, gcc produces 'synthesized method first required here' error. What is the problem, and how to correct the following program?</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  
  int main(int argc, char* argv[])
  {
      using namespace std;
      cout &lt;&lt; cin.rdbuf();    //OK
      ofstream("tmp.txt") &lt;&lt; cin.rdbuf(); //OK
  
      int i=1;
      (i &gt; 1 ? ofstream("tmp.txt") : cout) &lt;&lt; cin.rdbuf(); //Compilation ERROR. Why?
      return 0;
  }
  </code></pre>
  
  <p>compiled with gcc4.4:  </p>
  
  <pre><code>...    
  /usr/include/c++/4.4/bits/ios_base.h: In copy constructor ‘std::basic_ios&lt;char,   std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’:  
  /usr/include/c++/4.4/bits/ios_base.h:790: error: ‘std::ios_base::ios_base(const std::ios_base&amp;)’ is private  
  /usr/include/c++/4.4/iosfwd:47: error: within this context  
  /usr/include/c++/4.4/iosfwd: In copy constructor ‘std::basic_ostream&lt;char,   std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char,   std::char_traits&lt;char&gt; &gt;&amp;)’:  
  /usr/include/c++/4.4/iosfwd:56: note: **synthesized method** ‘std::basic_ios&lt;char,   std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)’   **first required here**   
  ../item1_1.cpp: In function ‘int main(int, char**)’:  
  ../item1_1.cpp:12: note: synthesized method ‘std::basic_ostream&lt;char,   std::char_traits&lt;char&gt; &gt;::basic_ostream(const std::basic_ostream&lt;char,   std::char_traits&lt;char&gt; &gt;&amp;)’ first required here   
  </code></pre>