Boost C++ Libraries: Ticket #6141: Compilation error when boost.thread and boost.move are used together https://svn.boost.org/trac10/ticket/6141 <p> Thread component has the definition "move" in boost/thread/detail/move.hpp, but new version of library contains the global description of "move" semantics in boost.move. It gives the conflict at compilation "ambiguous call to overloaded function". It is a code reproduces the given problem. </p> <pre class="wiki">#include &lt;boost/thread.hpp&gt; #include &lt;boost/move/move.hpp&gt; void func() { boost::shared_mutex mutex; boost::upgrade_lock&lt;boost::shared_mutex&gt; _upgrade_lock(mutex); boost::upgrade_to_unique_lock&lt;boost::shared_mutex&gt; _unique_lock(_upgrade_lock); // compilation error } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6141 Trac 1.4.3 nathan@… Fri, 02 Dec 2011 21:03:11 GMT cc set https://svn.boost.org/trac10/ticket/6141#comment:1 https://svn.boost.org/trac10/ticket/6141#comment:1 <ul> <li><strong>cc</strong> <span class="trac-author">nathan@…</span> added </li> </ul> Ticket anonymous Fri, 02 Dec 2011 22:59:55 GMT <link>https://svn.boost.org/trac10/ticket/6141#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:2</guid> <description> <p> <strong>Looks like I have the same problem (boost 1.48, MSVC2008):</strong><br /> </p> <p> enc_frame_queue.cpp:74: error: C2664: 'boost::upgrade_to_unique_lock&lt;Mutex&gt;::upgrade_to_unique_lock(boost::upgrade_to_unique_lock&lt;Mutex&gt; &amp;)' : cannot convert parameter 1 from 'boost::shared_lock&lt;Mutex&gt;' to 'boost::upgrade_to_unique_lock&lt;Mutex&gt; &amp;' with [ </p> <blockquote> <p> Mutex=boost::shared_mutex </p> </blockquote> <p> ] </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 05 Dec 2011 08:16:10 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6141#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:3</guid> <description> <p> Yes, same issue here. </p> </description> <category>Ticket</category> </item> <item> <author>blake-r@…</author> <pubDate>Mon, 05 Dec 2011 08:29:30 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6141#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:4</guid> <description> <pre class="wiki">--- a/locks.hpp 2011-12-05 12:26:11.650309054 +0400 +++ b/locks.hpp 2011-12-05 12:27:25.905311415 +0400 @@ -923,13 +923,13 @@ upgrade_to_unique_lock&amp; operator=(upgrade_to_unique_lock&amp;); public: explicit upgrade_to_unique_lock(upgrade_lock&lt;Mutex&gt;&amp; m_): - source(&amp;m_),exclusive(move(*source)) + source(&amp;m_),exclusive(move(detail::thread_move_t&lt;upgrade_lock&lt;Mutex&gt; &gt;(*source))) {} ~upgrade_to_unique_lock() { if(source) { - *source=move(exclusive); + *source=move(detail::thread_move_t&lt;unique_lock&lt;Mutex&gt; &gt;(exclusive)); } } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 11 Dec 2011 11:40:41 GMT</pubDate> <title>cc changed; keywords set https://svn.boost.org/trac10/ticket/6141#comment:5 https://svn.boost.org/trac10/ticket/6141#comment:5 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> <li><strong>keywords</strong> move added </li> </ul> <p> The is an action point to use Boost.Move. Could we consider this as a duplicate of <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6194" title="#6194: Feature Requests: Adapt to Boost.Move (closed: fixed)">#6194</a> Adapt to Boost.Move. </p> Ticket anonymous Mon, 12 Dec 2011 00:41:18 GMT <link>https://svn.boost.org/trac10/ticket/6141#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:6</guid> <description> <p> That's fine if you want to fix it when addressing <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6194" title="#6194: Feature Requests: Adapt to Boost.Move (closed: fixed)">#6194</a> - but this bug is actually a regression...code that used to work in 1.47.0 no longer even compiles in 1.48.0. It prevents you from using boost/thread/locks.hpp in conjunction with boost/unordered_map.hpp - since unordered map uses Boost::Move and thread locks use the other Boost::Move. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 12 Dec 2011 00:43:50 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6141#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:7</guid> <description> <p> In other words, I think this issue should actually be "upgraded" to a regression - instead of "downgraded" to a feature request (which <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6194" title="#6194: Feature Requests: Adapt to Boost.Move (closed: fixed)">#6194</a> is...) </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Hartmut Kaiser</dc:creator> <pubDate>Sun, 01 Jan 2012 22:06:23 GMT</pubDate> <title>severity changed https://svn.boost.org/trac10/ticket/6141#comment:8 https://svn.boost.org/trac10/ticket/6141#comment:8 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Showstopper</span> </li> </ul> Ticket Hartmut Kaiser Sun, 01 Jan 2012 22:07:52 GMT milestone changed https://svn.boost.org/trac10/ticket/6141#comment:9 https://svn.boost.org/trac10/ticket/6141#comment:9 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.49.0</span> </li> </ul> Ticket viboes Mon, 02 Jan 2012 02:47:10 GMT <link>https://svn.boost.org/trac10/ticket/6141#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:10</guid> <description> <p> The following patch in boost/move/move.hpp allows to avoid the issue provided Boost.Thread adds the needed specializations for has_move_emulation_enabled_aux. </p> <pre class="wiki"> svn diff Index: move.hpp =================================================================== --- move.hpp (revision 75884) +++ move.hpp (working copy) @@ -280,6 +280,10 @@ : BOOST_MOVE_BOOST_NS::integral_constant&lt;bool, false&gt; {}; + template &lt;class T&gt; + struct has_move_emulation_enabled_aux + : has_move_emulation_enabled&lt;T&gt; {}; + template &lt;class T&gt; struct has_nothrow_move : public BOOST_MOVE_BOOST_NS::integral_constant&lt;bool, false&gt; @@ -290,8 +294,9 @@ // move() // ////////////////////////////////////////////////////////////////////////////// + template &lt;class T&gt; - typename BOOST_MOVE_BOOST_NS::disable_if&lt;has_move_emulation_enabled&lt;T&gt;, T&amp;&gt;::type move(T&amp; x) + typename BOOST_MOVE_BOOST_NS::disable_if&lt;has_move_emulation_enabled_aux&lt;T&gt;, T&amp;&gt;::type move(T&amp; x) { return x; } </pre><p> Waiting for Ion response to see if he accepts this patch. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 02 Jan 2012 12:17:34 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6141#comment:11 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:11</guid> <description> <p> Boost.Move patch committed </p> <blockquote> <p> svn ci move.hpp -m "<a class="missing wiki">Move/Thread</a>: Added type tait so that <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6141" title="#6141: Bugs: Compilation error when boost.thread and boost.move are used together (closed: fixed)">#6141</a> - Compilation error when boost.thread and boost.move are used together - can be solved on the Boost.Thread side" </p> </blockquote> <p> Sending move.hpp Transmitting file data . Committed revision <a class="missing ticket">#76271</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Mon, 02 Jan 2012 17:14:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/6141#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6141#comment:12</guid> <description> <p> Committed in trunk at revision <a class="missing ticket">#76277</a> Boost.Thread part. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 03 Jan 2012 18:15:07 GMT</pubDate> <title>owner, status changed https://svn.boost.org/trac10/ticket/6141#comment:13 https://svn.boost.org/trac10/ticket/6141#comment:13 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Sat, 07 Jan 2012 20:53:02 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6141#comment:14 https://svn.boost.org/trac10/ticket/6141#comment:14 <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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/76346" title="Thread: merge from trunk to fix #6141, #5594, #5040 and #5502.">[76346]</a>) Thread: merge from trunk to fix <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6141" title="#6141: Bugs: Compilation error when boost.thread and boost.move are used together (closed: fixed)">#6141</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5594" title="#5594: Bugs: boost::shared_mutex not fully compatible with Windows CE. (closed: fixed)">#5594</a>, <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5040" title="#5040: Bugs: future.hpp in boost::thread does not compile with /clr (closed: fixed)">#5040</a> and <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5502" title="#5502: Patches: race condition between shared_mutex timed_lock and lock_shared (closed: fixed)">#5502</a>. </p> Ticket