Boost logo

Boost :

From: Neal D. Becker (ndbecker2_at_[hidden])
Date: 2004-11-09 07:15:02

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() {}
  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::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);

Boost list run by bdawes at, gregod at, cpdaniel at, john at