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) ); }
AMDG Archie14 wrote:
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>
boost::bind((&listofb::push_back), lstb, boost::bind((&operator new), b, _1) );
You'll most likely do better using Boost.Lambda. boost::lambda::bind(&listofb::push_back, lstb, boost::lambda::bind(boost::lambda::new_ptr<b>(_1))) In Christ, Steven Watanabe
participants (2)
-
Archie14
-
Steven Watanabe