Generalised the fix to all r-value input ranges.