Boost logo

Boost Users :

Subject: Re: [Boost-users] question about boost pointer
From: Ted Byers (r.ted.byers_at_[hidden])
Date: 2012-06-09 11:16:50


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of young
> Sent: June-09-12 10:34 AM
> To: boost-users_at_[hidden]
> Subject: Re: [Boost-users] question about boost pointer
>
> example:
>
> class MyClass
> {
> boost::shared_ptr<boost::shared_array&lt;char>> pBuff;
>
> void getnextpacket(size)
> {
> pBuff = boost::shared_ptr<boost::shared_array&lt;char>> (new
> boost::shared_array<char>(new char[size]));
> ...
> }
>
Why bother with boost::shared_ptr here? It adds nothing of value to the mix
that I can see.

Why not try something like:

class MyClass {
  private:
    boost:shared_array<char> pBuff;
  public:
    void getNextPacket(size) {
      pBuff.reset(new char[size]);
      ....
    }
    ...
}

Cheers

Ted


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