Quote Originally Posted by NMTop40
Why are you writing your own loop? What is wrong with std::find_if ?

Of course, it requires a functor. You can write one thus:

Code:
class node_name_is
{
   std::string searchName; // can also be const std::string & 
public:
   node_name_is( const std::string & sn ) : searchName( sn )
   {
   }
  
    bool operator() ( graph::node * pNode )
    {
        return searchName == pNode->name;
    }
};


list<graph::node*> const_iterator it =
   std::find_if( nodelist.begin(), nodelist.end(),
           node_name_is( node_name ) );

// check if it= nodelist.end()
Thanks. I couldn't find that method here, so I didn't know that it existed.
Quote Originally Posted by NMTop40
(I don't suggest you call your list list, although as long as you don't force namespace std in, there is no name-clash).
That's not one of my better examples of coding skills .