This is just the integer and pointer parts of std::midpoint.
The floating point bits and the lerp will come later.'
Details
Diff Detail
Event Timeline
libcxx/include/numeric | ||
---|---|---|
533 | Does const or volatile occur for by-value template parameters? | |
551 | Why the SFINAE? Just declare it midpoint(_Tp*, _Tp*) ? | |
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp | ||
29 | How about cases where the sum is odd? AKA 0, 3, 3, 0, 4, -1, and -1, 4). | |
32 | How about all these same tests but with -2 instead? |
libcxx/include/numeric | ||
---|---|---|
533 | I can remove that now that I realize that users are not supposed to explicitly list the template parameters. | |
551 | Because of this bad thing: midpoint<int>(0, 0) returns a int * Yes, I know that users are not supposed to do that, but this is easy prevention. | |
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp | ||
29 | I have more down below. |
Address Eric's comments.
Remove all the explicit template lists from the tests.
Add a couple "odd" tests.
Add a couple more failing pointer tests.
LGTM minus inline comments.
libcxx/include/numeric | ||
---|---|---|
529 | TODO on the floating point overloads? | |
549 | This overload isn't constexpr in the paper. | |
551 | The int case isn't quite right, but midpoint<long>(0, 0) triggers the bug you mention. Is there a test case? | |
553 | minpoint needs to be qualified. | |
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp | ||
31 | There's no reason why midpoint needs to be declared as a template. This test is non-portable. | |
64 | 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. |
Landed as r356162
libcxx/include/numeric | ||
---|---|---|
553 | I changed this to be: return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a); |
libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp | ||
---|---|---|
29 | I actually changed that before I committed. |
TODO on the floating point overloads?