Pretty nice! But I have a few things to point out:
First, gcc complains with this code because of those "typename typedef .." statements at the beginning of the MergeSort class. These don't make sense as you posted them, and I don't understand why your compiler would not complain. As you put it, it reads "I state a typename from defining the type std::vector as ArrayType" when it should read "I define a type from the typename std::vector called ArrayType". This corresponds to this code (just inverting the keywords):
typedef typename std::vector<Type> ArrayType;
typedef typename std::vector<Type>::const_iterator constItrType;
typedef typename std::vector<Type>::difference_type DiffType;
Then, well there is a bit of useless copying of vectors in your implementation. I know, a good compiler can do a lot of the optimization for you, but in this case it might be worth eliminating temporaries a bit more. After all, the purpose of MergeSort is to be efficient.
Finally, in _mergeSort, erasing elements from the vector "lhs" and "rhs" is useless and might very well destroy your performance by adding a O(N) complex calls in the middle of your merge loops, I haven't worked out the math or a test-benchmark, but I doubt it remains O(NlogN). Furthermore, allocating capacity for the result vector with a simple reserve() call will also make your push_back calls guaranteed to be O(1).
So, my mods to the two _mergeSort and _sortIt methods would look like this:
ArrayType _sortIt(constItrType begin, constItrType end)const{
if(end - begin < 2)
return ArrayType(begin,end);
DiffType mid = (end-begin) / 2;
return _mergeSort(_sortIt(begin, begin + mid ),_sortIt(begin + mid , end ));
}
ArrayType _mergeSort(const ArrayType& lhs, const ArrayType& rhs)const{
ArrayType result;
result.reserve(lhs.size() + rhs.size());
constItrType lhs_pos = lhs.begin();
constItrType rhs_pos = rhs.begin();
while((lhs_pos != lhs.end()) && (rhs_pos != rhs.end())){
if(compare(*lhs_pos,*rhs_pos))
result.push_back( *(lhs_pos++) );
else
result.push_back( *(rhs_pos++) );
}
std::copy(lhs_pos,lhs.end(), std::back_insert_iterator<ArrayType>(result) );
std::copy(rhs_pos,rhs.end(), std::back_insert_iterator<ArrayType>(result) );
return result;
}