[LLVMdev] set_intersect and Visual C compiler

Chris Lattner sabre at nondot.org
Tue Oct 12 12:08:06 PDT 2004


On Tue, 12 Oct 2004, Jeff Cohen wrote:

> I think a better version is:
>
> 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
>    }
> }
>
> This eliminates the use of a template templates while keeping the same
> flexibility.  Not that I actually to compile this...

That seems fine as well.  I don't have strong feelings about it either
way, so we'll use whatever works.  :)

-Chris

-- 
http://llvm.org/
http://nondot.org/sabre/




More information about the llvm-dev mailing list