
9 Nov
2004
9 Nov
'04
12:15 p.m.
Michiel Salters wrote:
The boost::function template works with boost::ref according to the docs, so try boost::function< int ( int ) > ( boost::ref( Op() ) )
Thanks. AFAICT, the best solution seems to be another set of algorithms, like this: struct Op { int operator() (int x) { return 1 + x;} Op() {} private: Op (const Op&); }; template<typename in_t, typename out_t, typename func> void transform_r (in_t const& in, out_t& out, func& f) { std::transform<typename boost::range_const_iterator<in_t>::type,typename boost::range_iterator<out_t>::type,func&> (boost::begin (in), boost::end (in), boost::begin (out), f); } int main() { vector<int> x (4); vector<int> y (4); Op o; transform_r (x, y, o); }