|
Boost Users : |
Subject: [Boost-users] using bind with operator new
From: Archie14 (admin_at_[hidden])
Date: 2009-05-19 17:42:22
I am trying to use bind to generate ptr_vector list of objects from another
vector
#include <boost/shared_ptr.hpp>
#include <boost/bind.hpp>
class a
{
};
class b
{
public:
b(a* val) : _val(val)
{
}
private:
boost::shared_ptr<a> _val;
};
void test()
{
boost::ptr_vector<a> lsta;
boost::ptr_vector<b> lstb;
typedef boost::ptr_vector<b> listofb;
// create lstb by applying new to each element of lsta and pushing it
to lstb. Fails. I will appreciate any help with this.
std::for_each (lsta.begin(), lsta.end,
boost::bind((&listofb::push_back), lstb,
boost::bind((&operator new), b, _1)
);
}
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