|
Boost Users : |
Subject: [Boost-users] [bind] and streaming operators for built in types.
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2009-08-26 17:35:16
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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net