Is it possible to get a raw pointer from boost:开发者_如何学C:weak_ptr? Boost\'s shared_ptr has get() method and \"->\" operator. Is there some rationale behind weak_ptr not having the same functional
Following the advice of this page, I\'m trying to get shared_ptr to call IUnknown::Release() instead of delete:
I\'m trying to use smart pointers such as auto_ptr, shared_ptr. However, I don\'t know how to use it in this situation.
How do shared pointers know how many pointers point to t开发者_JS百科hat object? (shared_ptr, in this case)Basically, shared_ptr has two pointers:a pointer to the shared object and a pointer to a stru
I remember encountering this concept before, but can\'t find it in Google now. If I have an object of type A, which directly embeds an object of type B:
Both code examples compile and run without problems. Using the second variant results in a memory leak. Any ideas why?
So, I use boost::shared_ptr for all the various reference-counting benefits it provides -- reference counting for starters, obviously, but also the ability to copy, assign, and therefore store in STL
using namespace boost; class A {}; class B : public A {}; class X { virtual shared_ptr<A> foo(); }; class Y : public X {
Suppose I have a rather large class Matrix, and I\'ve overloaded operator== to check for equality like so:
I have a thread A which allocates memory and assigns it to a shared pointer. Then this thread spawns 3 other threads X, Y and Z and passes a copy of the shared pointer to each. When X, Y and Z go out