I have the following code, which is supposed to add a shared_ptr instance to an intrusive linked list by thread A. Some other consumer thread will then use it later on by removing it from the list. However at a certain point my shared_ptr seems to get destroyed and the reference to it in the linked list is no longer valid resulting in ...
If I use a container of shared_ptrs and explicitely allow access to its elements, should I return shared_ptrs or raw pointers if I intend the container to be the one responsible for "cleaning up"?
class Container
{
private:
std:vector<shared_ptr<Foo> > foo_ptrs;
public:
shared_ptr<Foo> operator[](std::size_t index) const {}; //...
I want to ask you for your best practices regarding constructors in C++. I am not quite sure what I should do in a constructor and what not.
Should I only use it for attribute initializations, calling parent constructors etc.?
Or might I even put more complex functions into them like reading and parsing configuration data, setting up ex...
I have to share a BLOB in a multithreaded application and and I'm currently looking into shared_ptr/weak_ptr approach, but I'm not exactly sure it is correct.
There is a worker thread that creates a resource class (new CResource). CResource can be quite large, so I want to avoid extra copies.
Then there is another UI thread, I want to ...
Im working on this project,
The problem Im having is that the an object, does not really get deleted when I need it to be because it has a couple of shared pointers pointing to it.
How do I solve this,please help.
...
When I have a class that contains pointers as member variables what type of smart pointer should they have if I want don't want to use plain pointers? They do not need to be shared (so no shared_ptr necessary). scoped_ptr won't work since I often need to build the objects outside of the initialization list.
Or is it maybe common practic...
I'm using boost::shared_ptr's and boost::dynamic_pointer_cast. I have a base class, an interface that inherits from that base class, and then a class that inherits from that one.
So A -> B -> C. I create an object of type C and it's stored as a shared_ptr of type A. Then I try and do a dynamic_pointer_cast to type B, but boost::dynamic_...
I found some objects in my C++ program can't be released due to the Signal2 of boost won't release those arguments in object created by boost::bind. Here is the code to reproduce the problem:
#include <iostream>
#include <string>
#include <boost/bind.hpp>
#include <boost/signals2.hpp>
#include <boost/shared_ptr.hpp>
using namespace s...