Handle idx.modify(itr, mod) in boost >= 1.66 deleting *itr
Starting with boost 1.66, the modify method of the multi_index container stuff deletes the entry pointed to by iterator if the mod(itr) throws an exception.
This obviously causes problems here, as we do just that, hence the solver forgets components for the cost calculation.
This commit solves the problem by asserting the types before calling modify. It's a bit repetitive and ugly, but it works.