troubleshooting Question

How to use STL pair with vector?

Avatar of mikrodidakt
mikrodidakt asked on
Linux OS Dev
3 Comments1 Solution3550 ViewsLast Modified:

I am trying to do a lookup method by using a vector this is what i have done
typedef std::pair<std::string, int> pair_t;
typedef std::string HostName;              
typedef unsigned int IPAddress;

class VectorNameServer : public NameServerInterface {
            void insert(const HostName& hostname, const IPAddress& ipaddress);
            bool remove(const HostName& hostname);
            IPAddress lookup(const HostName& hostname) const;
            virtual ~VectorNameServer();            
            std::vector<pair_t> dns;      
void VectorNameServer::insert(const HostName& hostname, const IPAddress& ipaddress){
            dns.push_back(make_pair(hostname, ipaddress));      
IPAddress VectorNameServer::lookup(const HostName& hostname) const{
            vector<pair_t>::iterator itr = find_if(dns.begin(),dns.end(),
                  bind2nd(equal_to<pair_t>(), hostname));

I get a lot of error and i dont know how to use bind2nd together with the functor equal_to.
What should I do to get this work?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 3 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros