Boost logo

Boost Users :

From: Nat Goodspeed (ngoodspeed_at_[hidden])
Date: 2006-10-31 06:49:54


> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
> bounces_at_[hidden]] On Behalf Of Stephen Torri
> Sent: Monday, October 30, 2006 11:53 PM
> To: boost
> Subject: [Boost-users] Safe way to allocate block of memory
>
> I am trying to create a class which I can use to safely allocate a
block
> of bytes.
>
> My present method is create a block via 'new char[size]' and store
this
> pointer in a class.
>
> I was wondering if there was a boost method for creating an array of
> bytes?

[Nat] Have you tried using a std::vector<unsigned char>? You can get a
pointer to the first byte in the vector by &myVector[0]. Then
std::vector takes care of all the rest for you -- including allocation,
cleanup and the STL container support.


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