|
Boost Users : |
Subject: Re: [Boost-users] [shared_ptr] Using a custom delete function that is a class member function
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-10-09 19:40:23
AMDG
Ryan McConnehey wrote:
> I have a class that provides a shared_ptr number. At the end of the
> number's life cycle it should be placed back on a list of available
> numbers. The shared_ptr's custom deleter function looks like what I
> need. I'm able to get a free function to compile as the deleter just
> fine. In trying to use a class member function as the custom deleter
> I've run into compile errors. I'm not sure where I'm going wrong. I
> know the custom deleter need to be copy constructible and I'm probably
> breaking some assumed requirement. Any help on what I'm doing wrong
> would be appreciated.
> Ryan
>
>
> class CTNGenerator {
> public:
> CTNGenerator(void) {
> m_AvailableCTNs.resize(20);
> unsigned short startValue = 15;
>
> for (ctns::iterator itor = m_AvailableCTNs.begin(); itor !=
> m_AvailableCTNs.end(); ++itor) {
> //This compiles fine.
> boost::bind(boost::mem_fun(&CTNGenerator::makeCTNAvailable), this);
> //Placing the call as the custom delete function doesn't compile.
> *itor = bus(new unsigned short(startValue++),
> boost::bind(boost::mem_fun(&CTNGenerator::makeCTNAvailable, this)));
> }
> }
Check you parentheses. The two uses of bind/mem_fun are not the same.
In Christ,
Steven Watanabe
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