#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include struct point { point() {} point( double prob, double x ) : _prob( prob ), _x( x ) {} const double& prob() const { return _prob; } const double& x() const { return _x; } void set_prob( const double& prob ) { _prob = prob; } void set_x ( const double& x ) { _x = x; } private: double _prob; double _x; }; int _tmain(int argc, _TCHAR* argv[]) { using namespace std; using namespace boost::phoenix; using namespace boost::phoenix::arg_names; vector< point > points; ofstream out( ".\\remove.txt" ); // works std::for_each( points.begin() , points.end() , ref( out ) << bind( &point::prob, arg1 ) << ' ' ); // doesn't work - " " instead of ' ' std::for_each( points.begin() , points.end() , ref( out ) << bind( &point::prob, arg1 ) << " " ); // doesn't work std::for_each( points.begin() , points.end() , ref( out ) << bind( &point::prob, arg1 ) << ' ' << bind( &point::x, arg1 ) ); // doesn't work std::for_each( points.begin() , points.end() , ref( out ) << bind( &point::prob, arg1 ) << std::endl ); // doesn't work -- this is what I really wanna do. std::for_each( points.begin() , points.end() , ref( out ) << bind( &point::prob, arg1 ) << ' ' << bind( &point::x, arg1 ) << std::endl ); // works std::for_each( points.begin() , points.end() , cout << bind( &point::prob, arg1 ) << ' ' << bind( &point::x, arg1 ) << std::endl ); return 0; }