B
benben
I have the following code snippet:
class converter
{
// ...
public:
virtual polar_point convert_to_polar(const point&) = 0;
};
void f(const std::vector<point>& points, converter& cvt)
{
vector<polar_point> polarpoints(points.size());
for (unsigned int i = 0; i < points.size(); ++i)
{
polarpoints = cvt.convert(points);
}
print_points(polarpoints);
// ...
}
I'd like to replace the for loop with an appropriate std::transform
call. But I can't figure out what functor should I pass to transform...I
am thinking a number of combinations of mem_fun and bind1st/bind2nd, but
they don't seem to work.
Any ideas?
Ben
class converter
{
// ...
public:
virtual polar_point convert_to_polar(const point&) = 0;
};
void f(const std::vector<point>& points, converter& cvt)
{
vector<polar_point> polarpoints(points.size());
for (unsigned int i = 0; i < points.size(); ++i)
{
polarpoints = cvt.convert(points);
}
print_points(polarpoints);
// ...
}
I'd like to replace the for loop with an appropriate std::transform
call. But I can't figure out what functor should I pass to transform...I
am thinking a number of combinations of mem_fun and bind1st/bind2nd, but
they don't seem to work.
Any ideas?
Ben