|
Boost Users : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-12-05 09:15:50
sj_at_[hidden]:
> Hello,
>
> I'm upgrading from boost 1.33.1 to 1.34.1 and upgrade does not let me
> compile the following code:
>
> // CRefCounted provides functionality to CRefPtr to have
> // referenced pointers
> struct CNode: public CRefCounted
> {
> void GetName(){}
> };
>
> int main(int argc, char **argv){
> typedef CRefPtr<CNode> CPNode;
> typedef std::multimap<std::string, CPNode> TPNodes;
> TPNodes Children;
> std::for_each(
> Children.begin(),
> Children.end(),
> boost::bind(
> &CNode::GetName,
> // problem in the next line
> boost::bind(&TPNodes::value_type::second,_1)));
> return 0;
> }
>
> I get the following messages from MSVC8.0:
> error C2784: 'T *boost::get_pointer(const boost::shared_ptr<T> &)' :
> could not deduce template argument for 'const boost::shared_ptr<T> &'
> from 'const CPNode'
> error C2784: 'T *boost::get_pointer(const std::auto_ptr<_Ty> &)' : could
> not deduce template argument for 'const std::auto_ptr<_Ty> &' from
> 'const CPNode'
> error C2784: 'T *boost::get_pointer(T *)' : could not deduce template
> argument for 'T *' from 'const CPNode'
>
> If I replace CRefPtr with boost::shared_ptr the code compiles. Hence I
> assume the problem is with the way I implemented CRefPtr class. Here it
> is:
> template<typename T> class CRefPtr {
...
You need to implement get_pointer for CRefPtr. Add the following after
CRefPtr's definition:
template<class T> T* get_pointer( CRefPtr<T> const & p )
{
return p.get();
}
or use boost::intrusive_ptr.
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