C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
PengYu.UT@gmail.com
Guest





PostPosted: Wed Oct 18, 2006 5:28 am    Post subject: How to get the size of the array in boost::shared_array? Reply with quote



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





PostPosted: Wed Oct 18, 2006 7:32 am    Post subject: Re: How to get the size of the array in boost::shared_array? Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.