$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
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)
);
}