Opened 11 years ago

Closed 11 years ago

#6208 closed Bugs (fixed)

try_lock_wrapper swap compiler error on clang 3.0 c++11

Reported by: viboes Owned by: viboes
Milestone: Boost 1.49.0 Component: thread
Version: Boost 1.48.0 Severity: Problem
Keywords: Cc:

Description

While runing the regression test on clang-3.0/2.9 c++11 the following compile error appears

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:8:
In file included from ../../../boost/thread/mutex.hpp:16:
In file included from ../../../boost/thread/pthread/mutex.hpp:12:
../../../boost/thread/locks.hpp:991:15: error: base class 'unique_lock<boost::mutex>' has private copy constructor
        class try_lock_wrapper:
              ^
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<boost::detail::try_lock_wrapper<boost::mutex> >' requested here
    swap(left,right);
    ^
../../../boost/utility/swap.hpp:51:5: note: in instantiation of function template specialization 'boost_swap_impl::swap_impl<boost::detail::try_lock_wrapper<boost::mutex> >' requested here
    ::boost_swap_impl::swap_impl(left, right);
    ^
test_lock_concept.cpp:394:9: note: in instantiation of function template specialization 'boost::swap<boost::detail::try_lock_wrapper<boost::mutex>, boost::detail::try_lock_wrapper<boost::mutex> >' requested here
        swap(l1,l2);
        ^
test_lock_concept.cpp:453:5: note: in instantiation of member function 'test_locks_can_be_swapped<boost::mutex, boost::detail::try_lock_wrapper<boost::mutex> >::operator()' requested here
    test_locks_can_be_swapped<Mutex,Lock>()();


This is a similar problem to the one in #6207. The solution is


#ifndef BOOST_NO_RVALUE_REFERENCES
        template<typename Mutex>
        void swap(try_lock_wrapper<Mutex>&& lhs,try_lock_wrapper<Mutex>&& rhs)
        {
            lhs.swap(rhs);
        }
        template<typename Mutex>
        void swap(try_lock_wrapper<Mutex>& lhs,try_lock_wrapper<Mutex>& rhs)
        {
            lhs.swap(rhs);
        }
#else
        template<typename Mutex>
        void swap(try_lock_wrapper<Mutex>& lhs,try_lock_wrapper<Mutex>& rhs)
        {
            lhs.swap(rhs);
        }
#endif

Change History (3)

comment:1 by viboes, 11 years ago

Resolution: fixed
Status: newclosed

Committed in trunk revision 75801.

comment:2 by viboes, 11 years ago

Resolution: fixed
Status: closedreopened

Let close it when the merge is done.

comment:3 by viboes, 11 years ago

Resolution: fixed
Status: reopenedclosed

Committed in release at #76291

Note: See TracTickets for help on using tickets.