Remove code duplication regarding weak_ptr's less than operator.