Boost logo

Boost Users :

Subject: [Boost-users] boost::bind used with boost shared_ptr
From: Kevin Ludwig (kevin.ludwig_at_[hidden])
Date: 2009-03-04 13:55:21


Hi,

I've recently been making more use of boost::bind, and I coded the
following, which I thought would work:

class A {
    public:
    void reset () {}
};
typedef std::map<int, boost::shared_ptr<A> > map_type;
map_type m;
std::for_each (m.begin(), m.end(),
    boost::bind(&A::reset,
    boost::bind(&map_type::value_type::second, _1)));

but fails to compile. Next I tried this:

std::for_each (m.begin(), m.end(),
    boost::bind(&A::reset,
    boost::bind(&boost::shared_ptr<A>::get,
    boost::bind(&map_type::value_type::second, _1))));

Which works and is fine (I guess). I just wonder why the first syntax is
not supported? boost::shared_ptr is supposed to behave like a pointer (and
here it seems that it does not).

-- 
Kevin


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