Hi
I am facing to a design issue related to shared buffer management with shared_ptr. To summarize, the class below displays thi idea.
#include <memory>
using std::shared_ptr;
#include "Buffer.h"
class SharedBuffer : public shared_ptr<Buffer> {
private:
SharedBuffer next;
public:
SharedBuffer(Buffer* buffer = nullptr) : shared_ptr<Buffer>(buffer) {}
~SharedBuffer() {
if (next)
next.reset();
}
};
But this class is invalid since it is self referencing.
Any idea how to setup such shared buffer linked list class?
PS: The vector<shared_ptr<Buffer>> is not an option.