shared buffers as a single linked list

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.
1
2
3
private:
    SharedBuffer* next; // use a pointer directly, or better
                        // yet, wrap in unique_ptr 
Topic archived. No new replies allowed.