C++ Boost 1.48共享\u ptr成员作为自定义deallocator的功能(在这种情况下如何使用Boost bind)?

C++ Boost 1.48共享\u ptr成员作为自定义deallocator的功能(在这种情况下如何使用Boost bind)?,c++,class,boost,shared-ptr,C++,Class,Boost,Shared Ptr,我想学习boost共享指针中的自定义DealLocator 我包括: #include <string> #include <boost/shared_ptr.hpp> #include <boost/bind.hpp> 我该怎么办?如何修改使用custome deleterboost::shared_ptr(新std::string,boost::bind(&my_plugin::delete_ptr,_1))创建共享ptr的方式?我的绑定有什么问题?你的

我想学习boost共享指针中的自定义DealLocator

我包括:

#include <string>
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>

我该怎么办?如何修改使用custome deleter
boost::shared_ptr(新std::string,boost::bind(&my_plugin::delete_ptr,_1))创建共享ptr的方式?我的绑定有什么问题?

你的问题与
shared\u ptr
无关,你只是把
bind
用错了。@ildjarn:请你解释一下如何修复它好吗?没有测试过,但是试试
boost::bind(&my\u plugin::delete\u ptr,this,\u 1)
class deleter
{
    public:
    void delete_ptr(void * ptr)
    {
        delete ptr;
    };
};

class plugin: public deleter
{
public:
    virtual boost::shared_ptr<std::string> pass_and_modify_data( boost::shared_ptr<std::string>  a) =0;
};
#include "plug_in_interface.h"

class my_plugin: public plugin
{
    public:
    virtual boost::shared_ptr<std::string> pass_and_modify_data( boost::shared_ptr<std::string>  a)
        {
            return boost::shared_ptr<std::string>(new std::string,   boost::bind( &my_plugin::delete_ptr, _1 )  );
        }
};
Error   7   error C2440: 'newline' : cannot convert from 'std::string *' to 'deleter *' c:\program files (x86)\boost\include\boost-1_48\boost\bind\mem_fn.hpp   333 1   DemoPlugin
Error   8   error C2647: '->*' : cannot dereference a 'void (__thiscall deleter::* const )' on a 'std::string *'    c:\program files (x86)\boost\include\boost-1_48\boost\bind\mem_fn.hpp   333 1   DemoPlugin