Boost logo

Boost Users :

Subject: [Boost-users] upgrade_to_unique_lock doesn't compile with vc2010
From: Braden McDaniel (braden_at_[hidden])
Date: 2010-05-31 14:08:55


Using Boost 1.43, this program:

        # include <boost/thread.hpp>
        
        int main()
        {
          boost::shared_mutex mutex;
          boost::upgrade_lock<boost::shared_mutex> lock(mutex);
          boost::upgrade_to_unique_lock<boost::shared_mutex> write_lock(lock);
        }

... produces this error when compiled with Visual C++ 2010:

        C:\Users\braden>cl /I include/boost-1_43 /MD /EHsc upgrade_to_unique_lock_test.cpp
        Microsoft (R) C/C++ Optimizing Compiler Version 16.00.30319.01 for x64
        Copyright (C) Microsoft Corporation. All rights reserved.
        
        upgrade_to_unique_lock_test.cpp
        include/boost-1_43\boost/thread/locks.hpp(823) : error C2679: binary '=' : no operator found which takes a right-hand operand of type 'boost::unique_lock<Mutex>' (or there is no acceptable conversion)
                with
                [
                    Mutex=boost::shared_mutex
                ]
                include/boost-1_43\boost/thread/locks.hpp(659): could be 'boost::upgrade_lock<Mutex> &boost::upgrade_lock<Mutex>::operator =(boost::upgrade_lock<Mutex>&)'
                with
                [
                    Mutex=boost::shared_mutex
                ]
                include/boost-1_43\boost/thread/locks.hpp(710): or 'boost::upgrade_lock<Mutex> &boost::upgrade_lock<Mutex>::operator =(boost::detail::thread_move_t<T>)'
                with
                [
                    Mutex=boost::shared_mutex,
                    T=boost::upgrade_lock<boost::shared_mutex>
                ]
                include/boost-1_43\boost/thread/locks.hpp(717): or 'boost::upgrade_lock<Mutex> &boost::upgrade_lock<Mutex>::operator =(boost::detail::thread_move_t<T>)'
                with
                [
                    Mutex=boost::shared_mutex,
                    T=boost::unique_lock<boost::shared_mutex>
                ]
                while trying to match the argument list '(boost::upgrade_lock<Mutex>, boost::unique_lock<Mutex>)'
                with
                [
                    Mutex=boost::shared_mutex
                ]
                include/boost-1_43\boost/thread/locks.hpp(820) : while compiling class template member function 'boost::upgrade_to_unique_lock<Mutex>::~upgrade_to_unique_lock(void)'
                with
                [
                    Mutex=boost::shared_mutex
                ]
                upgrade_to_unique_lock_test.cpp(7) : see reference to class template instantiation 'boost::upgrade_to_unique_lock<Mutex>' being compiled
                with
                [
                    Mutex=boost::shared_mutex
                ]

I've searched a bit for previous reports of this sort of thing and I
haven't found any. Hopefully that means I'm just doing something wrong.

-- 
Braden McDaniel <braden_at_[hidden]>

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net