 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
PengYu.UT@gmail.com Guest
|
Posted: Wed Oct 18, 2006 5:28 am Post subject: 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 |
|
| Back to top |
|
 |
David Harmon Guest
|
Posted: Wed Oct 18, 2006 7:32 am Post subject: Re: How to get the size of the array in boost::shared_array? |
|
|
On 17 Oct 2006 17:28:40 -0700 in comp.lang.c++,
"PengYu.UT (AT) gmail (DOT) com" <PengYu.UT (AT) gmail (DOT) com> wrote,
| Quote: | 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. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|