True.  I would not expect a guarantee that malloc/free would be suitable for objects, since they came from a language that doesn’t have objects.  I was merely looking for a way to demonstrate manually calling both the constructor and destructor without calling either twice, and that happened to work on my platform, and I think will probably work on most.

 

Well, that and I didn’t know you could use operator new and operator delete like this.  We all learn something new every day.

 


From: Michael Nicolella [mailto:boost@mike-n.com]
Sent: Monday, July 10, 2006 2:54 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] std::vector< boost::shared_ptr<int> >::pop_back()

 

I would avoid malloc() and prefer the global operator new… I’m not sure if the standard guarantees that memory allocated with malloc is suitable for constructing an object in. My guess is there’s no such guarantee, but there is that guarantee for operator new. Or maybe I’m off my rocker.