| 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.
.
|
|
|
|

|
Related Articles |
|
|