Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-22 11:40:14


AMDG

Robert Dailey wrote:
> How about Boost.Bind? Could I use it to bind my operator? I would also
> expect it to choose the correct overload of the stream operator
> depending on the type of _1. I have not used Bind like this before, so
> I'm not sure if it is capable. If all else fails you've given me 2
> alternatives concerning Boost.Lambda, so I could always go with that.

To use bind you would have to wrap the stream operator in a function object.

struct stream_operator {
    typedef Stream& result_type;
    Stream& operator()(Stream& stream, char ch) const {
        return(stream << ch);
    }
};
...
boost::bind(stream_operator(), stream, _1);

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