[LLVMdev] set_intersect and Visual C compiler

Paolo Invernizzi arathorn at fastwebnet.it
Wed Oct 13 01:12:13 PDT 2004


Both are working well on VC. Just tested.

template<class STy>
void set_intersect(STy &S1, const STy &S2) {
  for(STy::iterator I = S1.begin(), E = S1.end(); I != E; )
    if (S2.count(*I))
      S1.erase(*I++);
    else
      ++I;
}

template <class S1Ty, class S2Ty>
void set_intersect(S1Ty &S1, const S2Ty &S2) {
   for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) {
     const S1Ty::key_type &E = *I;
     ++I;
     if (!S2.count(E)) S1.erase(E);   // Erase element if not in S2
   }
}

---
Paolo Invernizzi




More information about the llvm-dev mailing list