Slicing operation help

I eventually did it with using ranges with cv::Mat subarray = input_array(ranges); but the problem is that how do I re-apply the submatrix to the input_array. The internet suggests

cv::mat subarray = input_array(ranges)
cv::mat tmp = input_array.clone()
subarray.copyTo(tmp)