
The boost::function template works with boost::ref according to the docs, so try boost::function< int ( int ) > ( boost::ref( Op() ) ) HTH, Michiel Salters
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org]On Behalf Of Neal D. Becker Sent: maandag 8 november 2004 16:16 To: boost@lists.boost.org Subject: [boost] boost::ref simple question
This must be a common question.
I want to use std::transform with a function object that is expensive to copy, so I want to pass by reference. I tried to use boost::ref for this, but this simple test doesn't work:
struct Op { int operator() (int x) { return 1 + x;} Op() {} private: Op (const Op&);
};
int main() { vector<int> x (4); vector<int> y (4); Op o; std::transform (x.begin(), x.end(), y.begin(), boost::ref(o)); }
Any suggestion?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.