Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

No match for ‘boost::shared_ptr::operator=’

This is the code I have that causes the error below:

class CAlternateMerchantList
{
public:
    CAlternateMerchant::SP m_pAlternateMerchantList[MAX_PLAYER_LIST];
    int m_nMax;
    int m_nCur;

    CAlternateMerchantList()
    {
        int i;
        for (i = 0; i < MAX_PLAYER_LIST; i++)
            m_pAlternateMerchantList[i] = NULL;
        m_nMax = 0;
        m_nCur = 0;
    }

The error I get is the following:

PersonalShop.h: In constructor ‘CAlternateMerchantList::CAlternateMerchantList()’:
PersonalShop.h:227: error: no match for ‘operator=’ in ‘((CAlternateMerchantList*)this)->CAlternateMerchantList::m_pAlternateMerchantList[i] = 0’
/usr/local/include/boost-1_65_1/boost/smart_ptr/shared_ptr.hpp:547: note: candidates are: boost::shared_ptr<T>& boost::shared_ptr<T>::operator=(const boost::shared_ptr<T>&) [with T = CAlternateMerchant]

As you can see, I’m using boost 1_65_1 libraries. If I am not wrong, this code worked on another system with boost 1_59, but at the moment I can not access it for testing.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Does anyone know how to make this code work with boost 1.65? Or, is there any other issue here?

>Solution :

You don’t need to set boost::shared_ptrs to null. They have a default constructor which does it automatically. You can simply delete the entire for loop.

I suggest also using an initialization list for m_nMax and m_nCur.

CAlternateMerchantList()
    : m_nMax(0), m_nCur(0)
{
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading