Quick Q: How to use std:: pointers to implement data structures (say, a DAG)?—StackOverflow

Save to:
Instapaper Pocket Readability

This is a good specific example of a very common question about how to use smart pointers in data structures:

weak_ptr VS shared_ptr in graph node parent list

I have a directed acyclic graph implemented by Graph and Node classes. Each node has a list of pointers to children and a list of pointers to parents. [...] The Child list uses std::shared_ptr so that nodes are kept in memory at least as long as they have parents. But I don't want a node to own its parents, so I used weak_ptr for the pointers to parents.

But then there was a problem with the algorithms...

 

Add a Comment

You must sign in or register to add a comment.

Comments (0)

There are currently no comments on this entry.