<div dir="ltr">Hi llvm-dev,<div><br></div><div>Recently I try to specialize GraphTraits on my own graph. I found it hard to use, since it requires a hardcoded "NodeType *" in required function signatures. For example, for a graph like:</div><div><br></div><div>  struct Graph {</div><div>    struct Node {</div><div>      MachineInstr *data;</div><div>      unsigned EdgeBeginIndex, EdgeEndIndex;</div><div>    };</div><div>    struct Edge {</div><div>      unsigned LeftNodeIndex, RightNodeIndex;</div><div>    };</div><div>    std::vector<Node> Nodes;</div><div>    std::vector<Edge> SortedEdges;</div><div>  };</div><div><br></div><div>It can't be easily represented via a GraphTraits specialization, Since it's hard to let "NodeType *" carry necessary information - Nodes and SortedEdges - about its children. I can certainly add a SortedEdges vector pointer for each Node, but that seems unnecessary.</div><div><br></div><div>I propose to change the requirement from "NodeType*" to a typedef "NodePtr", so that users can customize their own "smarter" pointers. In the case above a NodePtr could be:</div><div><br></div><div>  struct NodePtr {</div><div>    Graph* G;</div><div>    unsigned Index;</div><div>    MachineInstr *&operator*() {</div><div>      return G->Nodes[Index];</div><div>    }</div><div>    // ...</div><div>  };</div><div><br></div><div>child_begin and child_end in GraphTraits will take NodePtr by value, and return ChildIteratorType. Dereferencing a ChildIteratorType returns a NodePtr by value. Dereferencing a nodes_iterator also returns a NodePtr by value.</div><div><br></div><div>Do you think this is a feasible change? If so, what is the preferred way to make this change/migration?</div><div><br></div><div>Thanks!</div></div>