Hello,
This is my first post on this mailing list, so bear with me... My name is Morten Ofstad and I work for Hue AS (www.hue.no), a company that makes 3D Visualization software. We are looking into using LLVM for JIT compiling shader programs, to replace our own (slow) VM. A requirement for this is that we can compile LLVM in VS7.1, so I contacted Paolo Invernizzi to find the status of his effort and to help out. I have set up the build environment now, with help from Paolo and have started to work on fixing some of the problems.
One thing that the compiler absolutely does not understand is the definition of set_intersect in include/llvm/ADT/SetOperations.h, and I am having a hard time understanding it myself.
template <template<class S1ElTy> class S1Ty, class ETy, class S2Ty>
void set_intersect(S1Ty<ETy> &S1, const S2Ty &S2) {
for (typename S1Ty<ETy>::iterator I = S1.begin(); I != S1.end() {
const ETy &E = *I;
++I;
if (!S2.count(E)) S1.erase(E); // Erase element if not in S2
}
}
it's only used in two places:
lib\Transforms\Scalar\LoopSimplify.cpp
lib\Analysis\PostDominators.cpp
both of which compile correctly if I replace it with the less generic
template<class STy>
void set_intersect(STy &S1, const STy &S2)
{
for(STy::iterator I = S1.begin(); I != S1.end(); ++I) {
if (S2.count(*I) > 0) {
S1.erase(*I);
}
}
}
Since I'm not very familiar with template programming, can someone explain to me the difference between these two implementations? I would like to keep the implementation as general as possible while still compiling under VS7.1, but I'm not that familiar with C++ template programming so I need a little help to understand better what is going on here...
m.