i facing design issue summarized following class: linked list of shared buffer linking element sharedbuffer
class sharedbuffer : public shared_ptr<buffer> { private: sharedbuffer _next; sharedbuffer(buffer* buffer) : shared_ptr<buffer>(buffer) {} ~sharedbuffer() { if (_next) _next.reset(); } };
this class wrong because references in own definition. idea. idea on making such list of shared buffer?
the short answer
you don't
there many container classes in stl. std::vector<>
, std::list<>
or whatever other container looking for. not roll own. please. make mistakes , time better spent working on program logic instead of debugging bad implementation of something, when implementations available free.
std::vector<std::shared_ptr<buffer>> sharedbuffers;
Comments
Post a Comment