|
Boost : |
Subject: Re: [boost] intrusive_ptr to a map containing intrusive_ptr object
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2011-09-14 15:07:34
On 09/14/2011 07:01 PM, shri kumar wrote:
> 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*&)'
>
> 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.
I'm not sure I understood what you're trying to do but the compiler
basically says that it can't construct intrusive_ptr from two arguments.
You seem to have confused intrusive_ptr with std::pair. Furthermore, it
seems odd to have intrusive_ptr on std::pair because std::pair doesn't
provide reference counting. You probably ether need shared_ptr instead
of intrusive_ptr or:
typedef std::pair<
ProtocolLibraryLoaderPtr,
boost::intrusive_ptr<ProtocolRecognizer_type>
> ProtocolLibEnginePair;
PS: And this thread is probably better suited for users' list.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk