Boost logo

Boost :

Subject: Re: [boost] [netlib] 0.8-beta now available!
From: Cliff Green (cliffg_at_[hidden])
Date: 2010-11-15 14:27:15


From: "Dean Michael Berris" <mikhailberis_at_[hidden]>

> ... I suppose this can be done with a pointer to a boost::asio::io_service
> and a flag that says
> whether the io_service is owned or provided by reference.

Unless I'm missing something, no flag is needed (warning - uncompiled code,
but based on real compilable code):

class some_net_lib {
public:
  // use internal io_service
  some_net_lib() : io_service_ptr(new boost::asio::io_service),
io_service_(*io_service_ptr) { }
  // use io_service provided by user
  some_net_lib(boost::asio::io_service& ios) : io_service_ptr(),
io_service_(ios) { }
private:
  // careful - declaration order of these two is very important
  std::auto_ptr<boost::asio::ios_service> io_service_ptr;
  boost::asio::ios_service& io_service_;
};

Obviously, all of the internal / implementation code will use io_service_.

Cliff
 


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk