C++ 共享\u ptr删除程序问题

C++ 共享\u ptr删除程序问题,c++,templates,c++14,shared-ptr,C++,Templates,C++14,Shared Ptr,我试图在shared_ptr中附加deleter函数,因为我们想集中我的内存,但遇到了一个奇怪的错误。请帮助我解决此错误: template<std::size_t size> class Allocator{ public: template<typename T> void Release(T *ptr) { } template<typename T> void GetMemory(std::shared_ptr<

我试图在
shared_ptr
中附加deleter函数,因为我们想集中我的内存,但遇到了一个奇怪的错误。请帮助我解决此错误:

template<std::size_t size> class Allocator{
public:
    template<typename T> void Release(T *ptr)
    {

    }
    template<typename T> void GetMemory(std::shared_ptr<T> &item)
    {
        T *ptr = new T();
        //my pain point is
        item =  std::shared_ptr<T>(ptr, 
        std::bind(&Allocator<size>::Release, this, std::placeholders::_1));
    }
};
模板类分配器{
公众:
模板无效释放(T*ptr)
{
}
模板void GetMemory(std::shared_ptr&item)
{
T*ptr=新的T();
//我的痛点是
项目=标准::共享ptr(ptr,
std::bind(&Allocator::Release,this,std::placeholders::\u 1));
}
};
错误是:

prog.cpp: In instantiation of 'void GetMemory(std::share_ptr<T> &item)  unsigned int size = 10u]':
prog.cpp:316:15:   required from here
prog.cpp:226:19: error: no matching function for call to 'bind(<unresolved overloaded function type>, Pool<10u>*, const std::_Placeholder<1>&)'
          std::bind(&Pool<test>::Release, this, std::placeholders::_1)); 
prog.cpp:void GetMemory(std::share_ptr&item)unsigned int size=10u]的实例化中:
程序cpp:316:15:此处需要
prog.cpp:226:19:错误:对“bind(,Pool*,const std::_Placeholder&)”的调用没有匹配的函数
std::bind(&Pool::Release,this,std::占位符::\u 1));

Pool::Release的定义是什么?听起来好像它有多个重载。请发布一个。抱歉,可能会复制问题:std::bind(&Allocator::Release,this,std::placeholders::_1));
Pool::Release
的定义是什么?听起来好像它有多个重载。请发布一个。抱歉,可能会复制问题:std::bind(&Allocator::Release,this,std::placeholders::_1));谢谢成功了!稍后我将探讨它。或者给我一些指示。让我检查一下运行时效果:)谢谢!成功了!稍后我将探讨它。或者给我一些指示。让我检查运行时效果:)
template<std::size_t size> class Allocator{
public:
    template<typename T> void Release(T *ptr)
    {

    }
    template<typename T> void GetMemory(std::share_ptr<T> &item)
    {
        T *ptr = new T();
        //my pain point is
        item =  std::shared_ptr<T>(ptr, 
        std::bind(&Allocator<size>::Release, this, std::placeholders::_1));
    }
};
item =  std::shared_ptr<T>(ptr, [&](auto x) { this->Release(x); });
item =  std::shared_ptr<T>(ptr, 
    std::bind(&Allocator<size>::template Release<T>, this, std::placeholders::_1));