Boost logo

Boost :

Subject: Re: [boost] [netlib] 0.8-beta now available!
From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2010-11-16 00:49:43


On Tue, Nov 16, 2010 at 3:27 AM, Cliff Green <cliffg_at_[hidden]> wrote:
> 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_.
>

Interesting. I was thinking that a unique_ptr would be more
appropriate, but as it currently stands using auto_ptr might make
sense in this case. It's worth a shot, thanks for the tip Cliff!

-- 
Dean Michael Berris
deanberris.com

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