>>529
> bool operator <(const StaffKey& lhs, const StaffKey& rhs) {
> return lhs.section < rhs.section || lhs.code < rhs.code;
> }

これが順序付けになってないっぽい。
↓これでいいかな?

if (lhs.section < rhs.section) return true; else if (rhs.section < lhs.section) return false;
return lhs.code < rhs.code;