This is just the integer and pointer parts of std::midpoint.
The floating point bits and the lerp will come later.'
Does const or volatile occur for by-value template parameters?
Why the SFINAE?
Just declare it midpoint(_Tp*, _Tp*) ?
How about cases where the sum is odd? AKA 0, 3, 3, 0, 4, -1, and -1, 4).
How about all these same tests but with -2 instead?
I can remove that now that I realize that users are not supposed to explicitly list the template parameters.
Because of this bad thing:
returns a int *
Yes, I know that users are not supposed to do that, but this is easy prevention.
I have more down below.
LGTM minus inline comments.
TODO on the floating point overloads?
This overload isn't constexpr in the paper.
The int case isn't quite right, but midpoint<long>(0, 0) triggers the bug you mention.
Is there a test case?
minpoint needs to be qualified.
There's no reason why midpoint needs to be declared as a template. This test is non-portable.
I think we need more constexpr test that try to tickle overflows and other boundary conditions to ensure we're constexpr in those cases as well.