Boost logo

Boost Users :

From: radiatejava (radiatejava_at_[hidden])
Date: 2023-02-09 00:15:30


I have an existing code for an application that uses
BOOST_DETAIL_SPINLOCK_INIT from boost/smart_ptr/detail/spinlock.hpp.
It is all fine when using with boost ver 1.53. I am trying to migrate
to boost ver 1.66 and now this compilation fails. To isolate the
issue, I have a sample program:

#include <iostream>
#include <boost/smart_ptr/detail/spinlock.hpp>
class BoostTest {
    public:
    BoostTest(int v): val(v), bLock(BOOST_DETAIL_SPINLOCK_INIT) {
        std::cout << "constructor called" << std::endl;
    }

    int getValue() {
        std::cout << "getValue() called" << std::endl;
        return val;
    }

    private:
    int val;
    boost::detail::spinlock bLock;
};

int main() {
    std::cout << "starting test" << std::endl;
    BoostTest bt(10);
    std::cout << "value now " << bt.getValue() << std::endl;
}

With ver 1.66, it now gives me the error. Why this error after upgrade
to 1.66? How do I correct it?
$ g++ -std=c++11
-I/data/hdd/code/mgmt/common/external/boost/ifc/dist/include -c
boosttest.cc
boosttest.cc: In constructor 'BoostTest::BoostTest(int)':
boosttest.cc:6:63: error: use of deleted function
'boost::detail::spinlock::spinlock(boost::detail::spinlock&&)'
     BoostTest(int v): val(v), bLock(BOOST_DETAIL_SPINLOCK_INIT) {
                                                               ^
In file included from
/data/hdd/code/mgmt/common/external/boost/ifc/dist/include/boost/smart_ptr/detail/spinlock.hpp:47:0,
                 from boosttest.cc:2:
/data/hdd/code/mgmt/common/external/boost/ifc/dist/include/boost/smart_ptr/detail/spinlock_std_atomic.hpp:27:7:
note: 'boost::detail::spinlock::spinlock(boost::detail::spinlock&&)'
is implicitly deleted because the default definition would be
ill-formed:
 class spinlock
       ^
/data/hdd/code/mgmt/common/external/boost/ifc/dist/include/boost/smart_ptr/detail/spinlock_std_atomic.hpp:27:7:
error: use of deleted function 'std::atomic_flag::atomic_flag(const
std::atomic_flag&)'
In file included from /usr/include/c++/4.8/atomic:41:0,
                 from
/data/hdd/code/mgmt/common/external/boost/ifc/dist/include/boost/smart_ptr/detail/spinlock_std_atomic.hpp:19,
                 from
/data/hdd/code/mgmt/common/external/boost/ifc/dist/include/boost/smart_ptr/detail/spinlock.hpp:47,
                 from boosttest.cc:2:
/usr/include/c++/4.8/bits/atomic_base.h:275:5: error: declared here
     atomic_flag(const atomic_flag&) = delete;
     ^


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