
Hi there, the following code doesn't compile since I'm iterating over a constant vector of points. struct point { double _prob; double _x; }; void test( const std::vector< point >& d ) { double sum_prob = std::accumulate( d.begin() , d.end() , 0.0 , arg1 + bind( &point::_prob, arg2 ) ); } int _tmain(int argc, _TCHAR* argv[]) { std::vector< point > d; test( d ); return 0; } My question is how can I convert or cast the "&point::_prob" into a const reference? I tried several ways but they all don't work. The only thing that worked was to add const getter function in my point structure. Like this: struct point { point( double prob, double x ) : _prob( prob ), _x( x ) {} const double& prob() const { return _prob; } double _prob; double _x; }; Thanks, Christian