CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Threaded View

  1. #1
    Join Date
    Feb 2002
    Posts
    5,757

    Search (Compare) Functor and std::pair :: STL

    Hi.

    How do you definte a comparison function for an container of std:air other than map? I need to search a container of std:air. For example:

    Code:
    typedef std::deque<std::pair<std::string, int> > deqStringInt;
    
    deqStringInt example;
    example.push_back(std::pair<"December", 21>);
    
    // How do you search an element?
    
    std::find_if(example.begin(), example.end(), std::bind2nd(???
    
    // Functor
    class Search : std::binary_function<std::pair<std::string, int>, std::string, bool>
    {
    public:
       bool operator()(const std::pair<std::string, int> &lp, const std::string &rp)
       {
          return lp->first == rp;
       }
    };
    Thanks,
    Kuphryn
    Last edited by kuphryn; December 21st, 2002 at 10:57 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured