Calculate the midpoint of two integers safely (without overflow).

std::midpoint(1, 3); // == 2