[libcxx-commits] [PATCH] D59099: Integer and pointer types of 'midpoint' from P0811

Eric Fiselier via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 8 20:47:48 PST 2019


EricWF added inline comments.


================
Comment at: libcxx/include/numeric:533
+{
+    using _Up = std::make_unsigned_t<remove_cv_t<_Tp>>;
+
----------------
Does `const` or `volatile` occur for by-value template parameters?


================
Comment at: libcxx/include/numeric:551
+enable_if_t<is_pointer_v<_TPtr>, _TPtr>
+midpoint(_TPtr __a, _TPtr __b) noexcept
+{
----------------
Why the SFINAE?

Just declare it `midpoint(_Tp*, _Tp*)` ?


================
Comment at: libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp:28
+    
+    assert(std::midpoint<T>(0,0)   == T(0));
+    assert(std::midpoint<T>(0,2)   == T(1));
----------------
How about cases where the sum is odd? AKA `0, 3`, `3, 0`, `4, -1`, and `-1, 4`).


================
Comment at: libcxx/test/std/numerics/numeric.ops/numeric.ops.midpoint/midpoint.integer.pass.cpp:31
+    assert(std::midpoint<T>(2,0)   == T(1));
+    assert(std::midpoint<T>(2,2)   == T(2));
+
----------------
How about all these same tests but with `-2` instead?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59099/new/

https://reviews.llvm.org/D59099





More information about the libcxx-commits mailing list