title: std::vector<std::ofstream>::erase is giving compile error
body: <p>Hi I'm trying to do some file operations and if needed user can open multiple files. I've created a vector derived <code>ofstream</code> but when I want to erase i. element (which file has closed) with <code>std::vector&lt;Type&gt;::erase(std::vector&lt;Type&gt;::iterator)</code> compiler is giving me error but I have another vector derived <code>std::string</code> and I'm erasing it same way it's not giving error. My codes are;</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  
  std::vector&lt;std::ofstream&gt; of;
  std::vector&lt;std::string&gt; sv;
  
  int CloseFile(int id, file_t ft) {
      std::vector&lt;std::ofstream&gt;::iterator i;
      std::vector&lt;std::string&gt;::iterator j;
      if (of[id].is_open() == true) {
          of[id].close();
          i = of.begin() + id;
          j = sv.begin() + id;
          of.erase(i); // showing error for this line
          sv.erase(j);
      }
  }
  </code></pre>
  
  <p>I'm using Nsight Eclipse Edition 6.0 on Ubuntu 12.04 and I need open file or files anyway the errors from Problem section of eclipse outputs are;</p>
  
  <ol>
  <li>required from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::basic_ofstream<em>; _OI = std::basic_ofstream</em>]</li>
  <li>required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator*, std::vector > >; _OI = __gnu_cxx::__normal_iterator*, std::vector > >]</li>
  <li>required from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator*, std::vector > >; _OI = __gnu_cxx::__normal_iterator*, std::vector > >]</li>
  <li>required from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator*, std::vector > >; _OI = __gnu_cxx::__normal_iterator*, std::vector > >]</li>
  <li>std::basic_streambuf&lt;_CharT, _Traits>&amp; std::basic_streambuf&lt;_CharT, _Traits>::operator=(const std::basic_streambuf&lt;_CharT, _Traits>&amp;) [with _CharT = char; _Traits = std::char_traits]</li>
  <li>std::ios_base&amp; std::ios_base::operator=(const std::ios_base&amp;)</li>
  <li>make: *** [dosya/dosya.o] Error 1</li>
  <li>within this content</li>
  <li>within this content</li>
  <li>required from here</li>
  </ol>
  
  <p><strong>The last error which is indicating code line</strong></p>
  
  <p>Compiler output:
  (Some words are in Turkish, dosya = file, GeriDonus_t = Return_t, DosyaKapat = FileClose)</p>
  
  <pre><code>16:06:56 **** Incremental Build of configuration Debug for project deneme ****`
  make all`
  Building file: ../dosya/dosya.cpp`
  Invoking: NVCC Compiler`
  /usr/local/cuda-6.0/bin/nvcc -I"/usr/local/cuda-6.0/samples/3_Imaging" -I"/usr/local    /cuda-6.0/samples/common/inc" -I"/opt/Calismalar/Cuda/cuda-workspace/deneme" -I/usr/local/opencv/include -I/usr/local/opencv/include/opencv -I/opt/Calismalar/Cuda/cuda-workspace/deneme/ -G -g -O0 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_32,code=sm_32  -odir "dosya" -M -o "dosya/dosya.d" "../dosya/dosya.cpp"`
  nvcc warning : The 'compute_10' and 'sm_10' architectures are deprecated, and may be removed in a future release.`
  /usr/local/cuda-6.0/bin/nvcc -I"/usr/local/cuda-6.0/samples/3_Imaging" -I"/usr/local/cuda-6.0/samples/common/inc" -I"/opt/Calismalar/Cuda/cuda-workspace/deneme" -I/usr/local/opencv/include -I/usr/local/opencv/include/opencv -I/opt/Calismalar/Cuda/cuda-workspace/deneme/ -G -g -O0 --compile  -x c++ -o  "dosya/dosya.o" "../dosya/dosya.cpp"
  In file included from /usr/include/c++/4.8/ios:42:0,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from ../dosya/dosya.h:13,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/bits/basic_ios.h: In instantiation of ‘static _OI std::__copy_move&lt;false, false, std::random_access_iterator_tag&gt;::__copy_m(_II, _II, _OI) [with _II = std::basic_ofstream&lt;char&gt;*; _OI = std::basic_ofstream&lt;char&gt;*]’:
  /usr/include/c++/4.8/bits/stl_algobase.h:390:70:   required from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::basic_ofstream&lt;char&gt;*; _OI = std::basic_ofstream&lt;char&gt;*]’
  /usr/include/c++/4.8/bits/stl_algobase.h:428:38:   required from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator&lt;std::basic_ofstream&lt;char&gt;*, std::vector&lt;std::basic_ofstream&lt;char&gt; &gt; &gt;; _OI = __gnu_cxx::__normal_iterator&lt;std::basic_ofstream&lt;char&gt;*, std::vector&lt;std::basic_ofstream&lt;char&gt; &gt; &gt;]’
  /usr/include/c++/4.8/bits/stl_algobase.h:460:17:   required from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator&lt;std::basic_ofstream&lt;char&gt;*, std::vector&lt;std::basic_ofstream&lt;char&gt; &gt; &gt;; _OI = __gnu_cxx::__normal_iterator&lt;std::basic_ofstream&lt;char&gt;*, std::vector&lt;std::basic_ofstream&lt;char&gt; &gt; &gt;]’
  /usr/include/c++/4.8/bits/vector.tcc:138:2:   required from ‘std::vector&lt;_Tp, _Alloc&gt;::iterator std::vector&lt;_Tp, _Alloc&gt;::erase(std::vector&lt;_Tp, _Alloc&gt;::iterator) [with _Tp = std::basic_ofstream&lt;char&gt;; _Alloc = std::allocator&lt;std::basic_ofstream&lt;char&gt; &gt;; std::vector&lt;_Tp, _Alloc&gt;::iterator = __gnu_cxx::__normal_iterator&lt;std::basic_ofstream&lt;char&gt;*, std::vector&lt;std::basic_ofstream&lt;char&gt; &gt; &gt;; typename std::_Vector_base&lt;_Tp, _Alloc&gt;::pointer = std::basic_ofstream&lt;char&gt;*]’
  ../dosya/dosya.cpp:152:27:   required from here
  /usr/include/c++/4.8/bits/ios_base.h:789:5: error: ‘std::ios_base&amp; std::ios_base::operator=(const std::ios_base&amp;)’ is private
       operator=(const ios_base&amp;);
       ^
  In file included from /usr/include/c++/4.8/ios:44:0,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from ../dosya/dosya.h:13,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/bits/basic_ios.h:66:11: error: within this context
       class basic_ios : public ios_base
             ^
  In file included from /usr/include/c++/4.8/iostream:39:0,
                   from ../dosya/dosya.h:13,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/ostream:58:11: note: synthesized method ‘std::basic_ios&lt;char&gt;&amp; std::basic_ios&lt;char&gt;::operator=(const std::basic_ios&lt;char&gt;&amp;)’ first required here 
       class basic_ostream : virtual public basic_ios&lt;_CharT, _Traits&gt;
             ^
  In file included from ../dosya/dosya.h:14:0,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/fstream:599:11: note: synthesized method ‘std::basic_ostream&lt;char&gt;&amp; std::basic_ostream&lt;char&gt;::operator=(const std::basic_ostream&lt;char&gt;&amp;)’ first required here 
       class basic_ofstream : public basic_ostream&lt;_CharT,_Traits&gt;
             ^
  In file included from /usr/include/c++/4.8/ios:43:0,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from ../dosya/dosya.h:13,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/streambuf:810:7: error: ‘std::basic_streambuf&lt;_CharT, _Traits&gt;&amp; std::basic_streambuf&lt;_CharT, _Traits&gt;::operator=(const std::basic_streambuf&lt;_CharT, _Traits&gt;&amp;) [with _CharT = char; _Traits = std::char_traits&lt;char&gt;]’ is private
         operator=(const basic_streambuf&amp;) { return *this; };
         ^
  In file included from ../dosya/dosya.h:14:0,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/fstream:72:11: error: within this context
       class basic_filebuf : public basic_streambuf&lt;_CharT, _Traits&gt;
             ^
  /usr/include/c++/4.8/fstream:599:11: note: synthesized method ‘std::basic_filebuf&lt;char&gt;&amp; &gt;std::basic_filebuf&lt;char&gt;::operator=(const std::basic_filebuf&lt;char&gt;&amp;)’ first required here 
       class basic_ofstream : public basic_ostream&lt;_CharT,_Traits&gt;
             ^
  In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                   from /usr/include/c++/4.8/ios:40,
                   from /usr/include/c++/4.8/ostream:38,
                   from /usr/include/c++/4.8/iostream:39,
                   from ../dosya/dosya.h:13,
                   from ../dosya/dosya.cpp:9:
  /usr/include/c++/4.8/bits/stl_algobase.h:335:18: note: synthesized method ‘std::basic_ofstream&lt;char&gt;&amp; std::basic_ofstream&lt;char&gt;::operator=(const std::basic_ofstream&lt;char&gt;&amp;)’ first required here 
          *__result = *__first;
                    ^
  make: *** [dosya/dosya.o] Error 1
  
  16:06:57 Build Finished (took 456ms)`
  </code></pre>
  
  <p>I have no idea for that. I've also looked <a href="https://stackoverflow.com/questions/19559235/stdvectorerase-and-const-iterators-with-g">this</a>, <a href="http://en.cppreference.com/w/cpp/container/vector/erase" rel="nofollow noreferrer">this</a>, <a href="http://www.cplusplus.com/reference/vector/vector/erase/" rel="nofollow noreferrer">this</a>, <a href="https://stackoverflow.com/questions/14779839/what-is-required-from-here-error">this</a> (it's about an eclipse <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=108720" rel="nofollow noreferrer">bug</a>), <a href="https://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.iterator_as_pod" rel="nofollow noreferrer">FAQ</a> - q7.1, <a href="https://stackoverflow.com/questions/13218108/required-from-here-error-declaring-a-list-of-lists">this</a> (about List but error is same and say error actually not error and I didn't change the compiler (nvcc)). Thanks everyone.</p>