Note that there are some explanatory texts on larger screens.

plurals
  1. POIs the move constructor of ifsteam implicitly deleted?
    primarykey
    data
    text
    <p>I have the following simple class:</p> <pre><code>class Source { public: Source() = default; Source(Source const&amp;) = delete; Source(Source&amp;&amp;) = default; explicit Source(std::string const&amp; fileName) : inputStream(fileName), path_(fileName) {} ~Source() = default; auto path() const -&gt; std::string { return this-&gt;path_; } std::ifstream inputStream; private: std::string path_; }; auto main(int argc, char* argv[]) -&gt; int { Source source(Source("test.txt")); cout &lt;&lt; source.path() &lt;&lt; "\n"; return 0; } </code></pre> <p>According to <a href="http://en.cppreference.com/w/cpp/io/basic_ifstream/basic_ifstream">cppreference</a> <code>ifstream</code> has a <code>move</code> constructor, but when I try to compile that with <code>MinGW 4.7.2</code>, I get the following error:</p> <blockquote> <p>..\src\main.cpp:32:46: error: use of deleted function 'cy::Source::Source(cy::Source&amp;&amp;)' In file included from ..\src\main.cpp:10:0: source.hpp:28:5: note: 'cy::Source::Source(cy::Source&amp;&amp;)' is implicitly deleted because the default definition would be ill-formed: source.hpp:28:5: error: use of deleted function 'std::basic_ifstream::basic_ifstream(const std::basic_ifstream&amp;)' c:\mingw\bin../lib/gcc/mingw32/4.7.2/include/c++/fstream:420:11: note: 'std::basic_ifstream::basic_ifstream(const std::basic_ifstream&amp;)' is implicitly deleted because the default definition would be ill-formed: c:\mingw\bin../lib/gcc/mingw32/4.7.2/include/c++/fstream:420:11: error: use of deleted function 'std::basic_istream::basic_istream(const std::basic_istream&amp;)'</p> </blockquote> <p>Am I doing something wrong? Or the documentation of cppreference is inaccurate? Or GCC 4.7.2 has a bug?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload