26 Aug
2009
26 Aug
'09
9:35 p.m.
Hi All I've asked a similar question before, but I can't seem to locate the mail or recall the answer! In the code below, how can I eliminate f()? #include "boost/iterator/counting_iterator.hpp" #include "boost/bind.hpp" #include <iostream> using namespace std; using namespace boost; ostream & f( ostream & s, int i ) { return s << i; } int main( ) { for_each( make_counting_iterator( 0 ), make_counting_iterator( 10 ), bind( & f, ref( cout ), _1 ) ); } If I write something like bind( static_cast< ostream & ( * )( ostream &, int ) >( operator << ), ref( cout ), _1 ) the compiler can't locate operator<<() Any thoughts, solutions even? Thanks, - Rob.