Sunday, 8 September 2013

Should I make my own comparator for pair of two smart pointers in map?

Should I make my own comparator for pair of two smart pointers in map?

I'm trying to create a template Graph Class, so I need to store Edges
somehow. I thought, that it might be great if I can access EdgeValue by
two Node smart pointers. But I don't actually know, how make it work. Now
it's something like this: template class Graph { typedef std::shared_ptr <
Node > NodePtr; std::map < std::pair < NodePtr, NodePtr > , EdgeValue>
Edges; } But I'm pretty sure, it would not work. Should I create compare
class or function? Should it be template? And actually, how to compare
smart pointers?

No comments:

Post a Comment