[libcxx-commits] [PATCH] D59099: Integer and pointer types of 'midpoint' from P0811
Marshall Clow via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 12 13:33:32 PDT 2019
mclow.lists marked 5 inline comments as done.
mclow.lists added inline comments.
================
Comment at: libcxx/include/numeric:533
+{
+ using _Up = std::make_unsigned_t<remove_cv_t<_Tp>>;
+
----------------
EricWF wrote:
> Does `const` or `volatile` occur for by-value template parameters?
I can remove that now that I realize that users are not supposed to explicitly list the template parameters.
================
Comment at: libcxx/include/numeric:551
+enable_if_t<is_pointer_v<_TPtr>, _TPtr>
+midpoint(_TPtr __a, _TPtr __b) noexcept
+{
----------------
EricWF wrote:
> Why the SFINAE?
>
> Just declare it `midpoint(_Tp*, _Tp*)` ?
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.
================
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));
----------------
EricWF wrote:
> How about cases where the sum is odd? AKA `0, 3`, `3, 0`, `4, -1`, and `-1, 4`).
I have more down below.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59099/new/
https://reviews.llvm.org/D59099
More information about the libcxx-commits
mailing list