[ create a new paste ] login | about

Link: http://codepad.org/VYNqdZeF    [ raw code | fork ]

C++, pasted on Nov 22:
#include <map>
#include <vector>
#include <string>

struct myStruct
{
  std::string a, b, c, id;
  bool operator<(const myStruct& rhs) const 
  {return id < rhs.id;}
};

struct checkId : unary_function<pair<myStruct, vector<size_t> >, bool>
{
private:
  std::string _exp;
public:
  checkId (myStruct& x) : _exp(x.id) {}
  bool operator() (const pair<myStruct, vector<size_t> > & p) const
  {
    return p.first.id.compare(_exp) == 0;
  }
};

int main() {
    typedef map<myStruct, std::vector<size_t> >::iterator iterator;
    map<myStruct, std::vector<size_t> > myMap;
    myStruct newS;  // to be initialized, but not shown here
    iterator it_mP2P = find_if(myMap.begin(), myMap.end(), checkId(newS));
    return 0;
}


Output:
No errors or program output.


Create a new paste based on this one


Comments: