Boost logo

Boost Users :

From: Darren Garvey (lists.drrngrvy_at_[hidden])
Date: 2007-02-20 14:03:28


Hi,

I'm trying to use bood::bind and I'm having a problem with compilation when
I'm passing an object that holds a std::stringstream. The errors are to do
with std::ios_base and std::streambuf's copy constructors being private, but
as far as I knew (and understand from the docs), boost::bind passes by
reference, so nothing should be copied. I'm sure I'm missing something
fundamental here, so any enlightening would be very welcome.

My setup is gcc 4.1.2 on Ubuntu 6.10. Here's an example program that fails:

#include <sstream>
> #include <boost/bind.hpp>
> #include <boost/thread.hpp>
>
> using namespace boost; // sorry
> using namespace std; // oops
>
>
> struct holder
> {
> std::ostringstream oss;
> };
>
> void sub_main( holder& h )
> {
> return;
> }
>
> class event_handler
> {
> public:
> void operator() ( holder& h )
> {
> thread t( bind( &sub_main, h ) );
> t.join();
> }
> };
>
> int main( int, char** )
> {
> event_handler e_h;
> holder h;
>
> e_h(h);
>
> return 0;
> }

Regards,
Darren



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