An empty range will mean a segfault when calling weights.back(), with the precondition, it will be more obvious.