You are trying to write objects to an empty
vector. You probably meant to use
v1.end(), v2.begin(), v2.end(),
(const Mclass& arg1,
const Mclass& arg2)
return (arg1.id < arg2.id);
Note the addition of using
std::back_inserter() to the output
range. Also, as Igor Tandetnik pointed out in a
comment, the predicate has to define a strict weak
order on the objects not an equality relation.
Note, that the inputs need to be sorted (in your
example you created them sorted).