Boost C++ Libraries: Ticket #6207: shared_lock swap compiler error on clang 3.0 c++11 https://svn.boost.org/trac10/ticket/6207 <p> While runing the regression test on clang-3.0/2.9 c++11 the following compile error appears </p> <pre class="wiki">clang-darwin.compile.c++ ../../../bin.v2/libs/thread/test/test_lock_concept.test/clang-darwin-2.9x/debug/threading-multi/test_lock_concept.o In file included from test_lock_concept.cpp:6: In file included from ../../../boost/test/unit_test.hpp:19: In file included from ../../../boost/test/test_tools.hpp:20: In file included from ../../../boost/test/unit_test_log.hpp:21: In file included from ../../../boost/test/tree/observer.hpp:20: In file included from ../../../boost/test/detail/global_typedef.hpp:18: In file included from ../../../boost/test/utils/basic_cstring/basic_cstring.hpp:21: In file included from ../../../boost/test/utils/basic_cstring/bcs_char_traits.hpp:25: In file included from /usr/include/c++/4.2.1/string:46: In file included from /usr/include/c++/4.2.1/bits/char_traits.h:45: /usr/include/c++/4.2.1/bits/stl_algobase.h:99:11: error: 'operator=' is a private member of 'boost::shared_lock&lt;boost::shared_mutex&gt;' __a = __b; ~~~ ^ ~~~ In file included from test_lock_concept.cpp:6: In file included from ../../../boost/test/unit_test.hpp:20: In file included from ../../../boost/test/unit_test_suite.hpp:21: In file included from ../../../boost/test/tree/test_case_template.hpp:31: In file included from ../../../boost/mpl/for_each.hpp:28: In file included from ../../../boost/utility/value_init.hpp:30: In file included from ../../../boost/swap.hpp:10: ../../../boost/utility/swap.hpp:33:5: note: in instantiation of function template specialization 'std::swap&lt;boost::shared_lock&lt;boost::shared_mutex&gt; &gt;' requested here swap(left,right); ^ ../../../boost/utility/swap.hpp:51:5: note: in instantiation of function template specialization 'boost_swap_impl::swap_impl&lt;boost::shared_lock&lt;boost::shared_mutex&gt; &gt;' requested here ::boost_swap_impl::swap_impl(left, right); ^ test_lock_concept.cpp:394:9: note: in instantiation of function template specialization 'boost::swap&lt;boost::shared_lock&lt;boost::shared_mutex&gt;, boost::shared_lock&lt;boost::shared_mutex&gt; &gt;' requested here swap(l1,l2); ^ test_lock_concept.cpp:535:44: note: in instantiation of member function 'test_locks_can_be_swapped&lt;boost::shared_mutex, boost::shared_lock&lt;boost::shared_mutex&gt; &gt;::operator()' requested here test_locks_can_be_swapped&lt;Mutex,Lock&gt;()(); </pre><p> I think the problem comes from this declaration: </p> <p> #ifndef BOOST_NO_RVALUE_REFERENCES </p> <blockquote> <p> template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp;&amp; lhs,shared_lock&lt;Mutex&gt;&amp;&amp; rhs) { </p> <blockquote> <p> lhs.swap(rhs); </p> </blockquote> <p> } </p> </blockquote> <p> #else </p> <blockquote> <p> template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp; lhs,shared_lock&lt;Mutex&gt;&amp; rhs) { </p> <blockquote> <p> lhs.swap(rhs); </p> </blockquote> <p> } </p> </blockquote> <p> #endif </p> <p> As I suspect that the overloading is not working. BTW, all the working swap overloads use the non moving interface. </p> <p> When I use instead </p> <blockquote> <p> template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp; lhs,shared_lock&lt;Mutex&gt;&amp; rhs) { </p> <blockquote> <p> lhs.swap(rhs); </p> </blockquote> <p> } </p> </blockquote> <p> the test works. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6207 Trac 1.4.3 viboes Sun, 04 Dec 2011 14:46:58 GMT component changed https://svn.boost.org/trac10/ticket/6207#comment:1 https://svn.boost.org/trac10/ticket/6207#comment:1 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> <p> Sorry I mean when I add the overloading </p> <pre class="wiki">#ifndef BOOST_NO_RVALUE_REFERENCES template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp;&amp; lhs,shared_lock&lt;Mutex&gt;&amp;&amp; rhs) { lhs.swap(rhs); } template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp; lhs,shared_lock&lt;Mutex&gt;&amp; rhs) { lhs.swap(rhs); } #else template&lt;typename Mutex&gt; void swap(shared_lock&lt;Mutex&gt;&amp; lhs,shared_lock&lt;Mutex&gt;&amp; rhs) { lhs.swap(rhs); } #endif </pre> Ticket viboes Sun, 04 Dec 2011 15:00:52 GMT cc set https://svn.boost.org/trac10/ticket/6207#comment:2 https://svn.boost.org/trac10/ticket/6207#comment:2 <ul> <li><strong>cc</strong> <span class="trac-author">viboes</span> added </li> </ul> <p> Committed in trunk revision 75801. </p> Ticket viboes Sun, 04 Dec 2011 23:40:00 GMT status changed https://svn.boost.org/trac10/ticket/6207#comment:3 https://svn.boost.org/trac10/ticket/6207#comment:3 <ul> <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 22:57:50 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6207#comment:4 https://svn.boost.org/trac10/ticket/6207#comment:4 <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> Committed in release at <a class="missing ticket">#76291</a> </p> Ticket