How to get the size of the array in boost::shared_array?



 DEVELOP > c-Plus-Plus > How to get the size of the array in boost::shared_array?

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 17 Oct 2006 07:28:40 PM
Object: How to get the size of the array in boost::shared_array?
Hi,
I remember that the main difference between "int * a = new
std::complex<double>;" and "int *b = new std::complex<double>[10]" is
that the compiler keep the size of the array that "b" pointing to. So
"delete [] b" will call "std::complex<double>"'s destructor 10 times.
If that is the case, can we have any way to know the size of the array
the shared_array pointing to?
Thanks,
Peng
.

User: "David Harmon"

Title: Re: How to get the size of the array in boost::shared_array? 17 Oct 2006 09:32:36 PM
On 17 Oct 2006 17:28:40 -0700 in comp.lang.c++,
"PengYu.UT@gmail.com" <PengYu.UT@gmail.com> wrote,

If that is the case, can we have any way to know the size of the array
the shared_array pointing to?

In general, you cannot get that information. Not any more than you
can for a naked pointer to a new[]'ed array.
If you need the size remembered for you, use the more general and
standard mechanism of std::vector<>. If you need shared management,
a boost::shared_pointer to the vector will do that for you.
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER