On Sat, Jun 9, 2012 at 8:16 AM, Ted Byers
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of young Sent: June-09-12 10:34 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] question about boost pointer
example:
class MyClass { boost::shared_ptrboost::shared_array<char> pBuff;
void getnextpacket(size) { pBuff = boost::shared_ptrboost::shared_array<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 mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
There's also the question of why you need a shared_ptr or shared_array here at all. Will the array be passed around where you can't easily scope the lifetime of the data? Brian