If std::for_each is acceptable then the following works. Or do you specifically
need std::transform?
//////////////////////
#include <algorithm>
#include <vector>
#include <iostream>
#include
#include
#include
struct point
{
double _prob;
double _x;
};
point make_point(double prob, double x)
{
point const p = { prob, x };
return p;
}
int main()
{
namespace phx = boost::phoenix;
using namespace phx::arg_names;
typedef std::vector<point> points_t;
points_t points;
points.push_back(make_point(1., 5.));
points.push_back(make_point(2., 6.));
points.push_back(make_point(3., 7.));
points.push_back(make_point(4., 8.));
std::for_each(
points.begin(),
points.end(),
phx::bind(&point::_prob, _1) *= 2.
);
for (points_t::const_iterator i = points.begin(), i_end = points.end();
i != i_end; ++i)
std::cout << i->_prob << ' ' << i->_x << std::endl;
return 0;
}