|
Boost Users : |
Subject: Re: [Boost-users] [bind] and streaming operators for built in types.
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-08-26 17:44:51
AMDG
Robert Jones wrote:
> 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?
>
operator<< for int a member function.
template<class charT, class traits>
basic_ostream<charT,traits>&
std::basic_ostream<charT,traits>::operator<<(int n);
In Christ,
Steven Watanabe
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