Boost C++ Libraries: Ticket #11570: Boost 1.59.0 breaks lexical_cast to a move-only type (from a string) https://svn.boost.org/trac10/ticket/11570 <p> I think lexical_cast 1.59.0 introduces a regression over 1.58.0 because 1.58.0 allows lexical_cast from string to a move-only type but this now fails to compile. </p> <p> C++11 example: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/lexical_cast.hpp&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;iostream&gt;</span><span class="cp"></span> <span class="cp">#include</span> <span class="cpf">&lt;string&gt;</span><span class="cp"></span> <span class="k">using</span> <span class="n">boost</span><span class="o">::</span><span class="n">lexical_cast</span><span class="p">;</span> <span class="k">using</span> <span class="k">namespace</span> <span class="n">std</span><span class="p">;</span> <span class="k">struct</span> <span class="n">my_move_only</span> <span class="k">final</span> <span class="p">{</span> <span class="n">string</span> <span class="n">data</span><span class="p">;</span> <span class="n">my_move_only</span><span class="p">()</span> <span class="o">=</span> <span class="k">default</span><span class="p">;</span> <span class="n">my_move_only</span><span class="p">(</span><span class="n">my_move_only</span> <span class="o">&amp;&amp;</span><span class="p">)</span> <span class="o">=</span> <span class="k">default</span><span class="p">;</span> <span class="n">my_move_only</span><span class="p">(</span><span class="k">const</span> <span class="n">my_move_only</span> <span class="o">&amp;</span><span class="p">)</span> <span class="o">=</span> <span class="k">delete</span><span class="p">;</span> <span class="p">};</span> <span class="n">istream</span> <span class="o">&amp;</span> <span class="k">operator</span><span class="o">&gt;&gt;</span><span class="p">(</span><span class="n">istream</span> <span class="o">&amp;</span><span class="n">arg_is</span><span class="p">,</span> <span class="n">my_move_only</span> <span class="o">&amp;</span><span class="n">arg_mot</span><span class="p">)</span> <span class="p">{</span> <span class="n">arg_is</span> <span class="o">&gt;&gt;</span> <span class="n">arg_mot</span><span class="p">.</span><span class="n">data</span><span class="p">;</span> <span class="k">return</span> <span class="n">arg_is</span><span class="p">;</span> <span class="p">}</span> <span class="kt">int</span> <span class="n">main</span><span class="p">()</span> <span class="p">{</span> <span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;from string gives : &quot;</span> <span class="o">&lt;&lt;</span> <span class="n">lexical_cast</span><span class="o">&lt;</span><span class="n">my_move_only</span><span class="o">&gt;</span><span class="p">(</span> <span class="n">string</span><span class="p">{</span> <span class="s">&quot;mr_carbohdrate&quot;</span> <span class="p">}</span> <span class="p">).</span><span class="n">data</span> <span class="o">&lt;&lt;</span> <span class="n">endl</span><span class="p">;</span> <span class="p">}</span> </pre></div></div><p> This works against Boost 1.58.0 under both <code>g++ -std=c++11</code> and <code>clang++ -std=c++11 -stdlib=libc++</code> but fails against Boost 1.59.0 under both. </p> <p> The key compile error message appears to be: </p> <pre class="wiki">boost/lexical_cast.hpp:46:26: error: use of deleted function ‘my_move_only::my_move_only(const my_move_only&amp;)’ return get(result); </pre><p> (ie, you're trying to copy-construct this move-only type). </p> <p> It looks to me like this functionality broke with commit <a class="ext-link" href="https://github.com/boostorg/lexical_cast/commit/bdc355759e3259209f1107ae21babee6dcf8d80b"><span class="icon">​</span>bdc355759e</a>. </p> <p> Is it possible to keep that commit's benefits whilst restoring support for move-only types? Perhaps with some <code>std::move()</code> magic? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11570 Trac 1.4.3 Antony Polukhin Fri, 25 Sep 2015 17:53:53 GMT status, milestone changed https://svn.boost.org/trac10/ticket/11570#comment:1 https://svn.boost.org/trac10/ticket/11570#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.60.0</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/lexical_cast/commit/424320d9a18b17c55c86012673722ca1b42dcfa9"><span class="icon">​</span>Reverted the commit</a>. Attempted to <a class="ext-link" href="https://github.com/boostorg/lexical_cast/commit/038e80ec7a7f34f61379c8885f386b230ef09624"><span class="icon">​</span>suppress the warnings in this commit</a>. </p> Ticket Antony Polukhin Tue, 17 Nov 2015 19:49:29 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/11570#comment:2 https://svn.boost.org/trac10/ticket/11570#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket lopresti@… Fri, 01 Apr 2016 18:06:05 GMT <link>https://svn.boost.org/trac10/ticket/11570#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11570#comment:3</guid> <description> <p> See <a class="ext-link" href="https://github.com/boostorg/lexical_cast/pull/18"><span class="icon">​</span>https://github.com/boostorg/lexical_cast/pull/18</a> and /19. </p> </description> <category>Ticket</category> </item> <item> <author>Tony Lewis <tonyelewis@…></author> <pubDate>Wed, 06 Apr 2016 20:59:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11570#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11570#comment:4</guid> <description> <p> Still looks good to me. Thanks to all for the work on this. </p> </description> <category>Ticket</category> </item> </channel> </rss>