Boost logo

Boost :

From: John Hunter (jdhunter_at_[hidden])
Date: 2001-08-16 10:19:16


I have a container of shared pointers and I want to call a member
function which returns a value and place that return value into
another container using transform

class Neuron {
public:
  ...
  const Train<float_t>* get_ptr_train() const { return &st; }
  ....
};

std::vector<boost::shared_ptr<Neuron> nrns;
std::vector<boost::shared_ptr<const Train<float_t> > trains;

...

std::transform(nrns.begin(), nrns.end(), trains.begin(),
          boost::mem_fun(&Neuron::get_ptr_train));

But I get the compiler error

/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/stl_algo.h: In function `const class Train<double> ** transform<PtrNeuron *, const Train<double> **, boost::const_mem_fun_t<const Train<double> *,Neuron> >(PtrNeuron *, PtrNeuron *, const Train<double> **, boost::const_mem_fun_t<const Train<double> *,Neuron>)':
NeuralNetwork.cpp:15: instantiated from here
/usr/local/lib/gcc-lib/i686-pc-linux-gnu/2.95.2/../../../../include/g++-3/stl_algo.h:451: no match for call to `(boost::const_mem_fun_t<const Train<double> *,Neuron>) (boost::shared_ptr<Neuron> &)'
/home/guest/jdhunter/c/lib/boost/functional.hpp:360: candidates are: const class Train<double> * boost::const_mem_fun_t<const Train<double> *,Neuron>::operator ()(const Neuron *) const

What is the right way to do what I am trying to do. Do I need an
iterator_adaptor?

Thanks,
John Hunter

 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk