Boost C++ Libraries: Ticket #9211: fstream types don't have move semantics https://svn.boost.org/trac10/ticket/9211 <p> boost::filesystem::ofstream etc. lack move semantics for c++11, so they can't be used as a replacement for std::ofstream etc. if move semantics are required </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9211 Trac 1.4.3 viboes Tue, 08 Oct 2013 17:24:08 GMT type changed https://svn.boost.org/trac10/ticket/9211#comment:1 https://svn.boost.org/trac10/ticket/9211#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Feature Requests</span> </li> </ul> <p> How is this a bug? </p> Ticket anonymous Wed, 09 Oct 2013 07:55:09 GMT <link>https://svn.boost.org/trac10/ticket/9211#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9211#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/9211#comment:1" title="Comment 1">viboes</a>: </p> <blockquote class="citation"> <p> How is this a bug? </p> </blockquote> <p> I understand the filesystem::fstream classes as drop-in replacements for the std ones to support filesystem::path. When a feature that prevents intended operation is missing, I think of it as a bug rather than a feature request, but it's probably a matter of definition. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 24 Mar 2014 09:36:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/9211#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9211#comment:3</guid> <description> <p> Here is a use case: </p> <pre class="wiki">template &lt;typename Stream, typename... Args&gt; Stream StreamOpen(Args&amp;&amp;... args) { Stream stream; stream.exceptions(ios::failbit | ios::badbit); stream.open(forward&lt;Args&gt;(args)...); return stream; } </pre><pre class="wiki">auto f1 = StreamOpen&lt;std::ifstream&gt;("filename", std::ios::binary); // succeeds auto f2 = StreamOpen&lt;boost::filesystem::ifstream&gt;("filename", std::ios::binary); // fails </pre> </description> <category>Ticket</category> </item> <item> <author>mail@…</author> <pubDate>Sun, 04 May 2014 11:33:23 GMT</pubDate> <title>cc set https://svn.boost.org/trac10/ticket/9211#comment:4 https://svn.boost.org/trac10/ticket/9211#comment:4 <ul> <li><strong>cc</strong> <span class="trac-author">mail@…</span> added </li> </ul> Ticket anonymous Tue, 27 May 2014 11:37:01 GMT summary changed https://svn.boost.org/trac10/ticket/9211#comment:5 https://svn.boost.org/trac10/ticket/9211#comment:5 <ul> <li><strong>summary</strong> <span class="trac-field-old">fstream types don't have move semantics</span> → <span class="trac-field-new">fstream types don't have move semantics or swap method</span> </li> </ul> <p> <code></code><code>boost::filesystem::*fstream</code><code></code> are missing the <code></code><code>swap</code><code></code> methods from <code></code><code>std::*fstream</code><code></code> as well. Since the boost classes don't have any data, would just adding stubs that call the std ones be enough? </p> Ticket anonymous Tue, 27 May 2014 12:07:03 GMT summary changed https://svn.boost.org/trac10/ticket/9211#comment:6 https://svn.boost.org/trac10/ticket/9211#comment:6 <ul> <li><strong>summary</strong> <span class="trac-field-old">fstream types don't have move semantics or swap method</span> → <span class="trac-field-new">fstream types don't have move semantics</span> </li> </ul> <p> Actually the boost classes don't need <code>swap</code> methods of their own, they can just use the ones inherited from std: </p> <pre class="wiki">class myifstream : public boost::filesystem::ifstream { myifstream() { } myifstream(myifstream&amp;&amp; other) { swap(other); } myifstream&amp; operator=(myifstream&amp;&amp; other) { swap(other); return *this; } }; </pre><pre class="wiki">auto f3 = StreamOpen&lt;myifstream&gt;("filename", std::ios::binary); // succeeds </pre> Ticket