Boost logo

Boost :

Subject: [boost] intrusive_ptr to a map containing intrusive_ptr object
From: shri kumar (tezkrishna_at_[hidden])
Date: 2011-09-14 11:01:16


Hi,

I am facing a problem while making the raw pointer to an intrusive_ptr
inside a map whose pointer is already an intrusive pointer so typedef goes
like:

typedef boost::intrusive_ptr< protocolLibraryLoader>
ProtocolLibraryLoaderPtr;

typedef std::pair<ProtocolLibraryLoaderPtr, ProtocolRecognizer_type*>
ProtocolLibEnginePair;

typedef boost::intrusive_ptr<ProtocolLibEnginePair>
ProtocolLibEnginePairPtr;

Now inside code when I try creating map and assign with ptr as given in
below:

..

        *boost::intrusive_ptr<protocolLibraryLoader> libraryLoader =
getProtoLoader();*

        ..

        m_activeRecEnginePtr =
ProtocolLibEnginePairPtr(libraryLoader,newRecognizer);

..

I get the following error:

ProtocolManager.cpp: In member function 'void
ProtocolManager::InitializeProtocolsLibrary(ProtocolManager*)':

ProtocolManager.cpp:234: error: no matching function for call to
'boost::intrusive_ptr<std::pair<boost::intrusive_ptr<protocolLibraryLoader>,
ProtocolRecognizer_type*>
>::intrusive_ptr(boost::intrusive_ptr<protocolLibraryLoader>&,
ProtocolRecognizer_type*&)'

../../../include/boost/intrusive_ptr.hpp:94: note: candidates are:
boost::intrusive_ptr<T>::intrusive_ptr(const boost::intrusive_ptr<T>&) [with
T = std::pair<boost::intrusive_ptr<protocolLibraryLoader>,
ProtocolRecognizer_type*>]

../../../include/boost/intrusive_ptr.hpp:70: note:
      boost::intrusive_ptr<T>::intrusive_ptr(T*, bool) [with T =
std::pair<boost::intrusive_ptr<protocolLibraryLoader>,
ProtocolRecognizer_type*>]

../../../include/boost/intrusive_ptr.hpp:66: note:
boost::intrusive_ptr<T>::intrusive_ptr() [with T =
std::pair<boost::intrusive_ptr<protocolLibraryLoader>,
ProtocolRecognizer_type*>]

../../../include/boost/intrusive_ptr.hpp: In constructor
'boost::intrusive_ptr<T>::intrusive_ptr(T*, bool) [with T =
protocolLibraryLoader]':

ProtocolManager.cpp:225: instantiated from here

../../../include/boost/intrusive_ptr.hpp:72: error: cannot convert
'protocolLibraryLoader*' to 'Tracker*' for argument '1' to 'void
intrusive_ptr_add_ref(Tracker*)'

../../../include/boost/intrusive_ptr.hpp: In destructor
'boost::intrusive_ptr<T>::~intrusive_ptr() [with T =
protocolLibraryLoader]':

ProtocolManager.cpp:225: instantiated from here

../../../include/boost/intrusive_ptr.hpp:101: error: cannot convert
'protocolLibraryLoader*' to 'Tracker*' for argument '1' to 'void
intrusive_ptr_release(Tracker*)'

../../../include/boost/intrusive_ptr.hpp: In copy constructor
'boost::intrusive_ptr<T>::intrusive_ptr(const boost::intrusive_ptr<T>&)
[with T = protocolLibraryLoader]':

ProtocolManager.cpp:225: instantiated from here

../../../include/boost/intrusive_ptr.hpp:96: error: cannot convert
'protocolLibraryLoader*' to 'Tracker*' for argument '1' to 'void
intrusive_ptr_add_ref(Tracker*)'

make: *** [FREEBSD_6_i686/ProtocolManager.o] Error 1

Basically worrying part is "no matching function for call to
'boost::intrusive_ptr<std::pair<boost::intrusive_ptr<protocolLibraryLoader>,
ProtocolRecognizer_type*>
>::intrusive_ptr(boost::intrusive_ptr<protocolLibraryLoader>&,
ProtocolRecognizer_type*&)'

I wonder if it is kind of limitation or do I have to do something else to
achieve?

Actually I am dealing with legacy code so I don't want to remove the
intrusiveness on the pair which actually increases/decreases ref_count of
ProtocolRecognizer_type and not on protocolLibraryLoader.

Please help me as I am kind of stuck with this.

Thanks

Shri


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk