You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In C++17, clamp(v, lo, hi) uses operator< to do the comparison.
In C++20 and beyond, clamp(v, lo, hi) uses std::less{} to do the comparison. I'm not sure why it changed (I cannot find the LWG issue), but I suspect this has something to do with clamping pointers.
Should we change, and if so, should that change be dependent on the C++ version?
My answer to the above is yes and no.
The text was updated successfully, but these errors were encountered:
std::less<void> from clang does return std::forward<_T1>(__t) < std::forward<_T2>(__u);. std::less<void> from gcc does return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u), __ptr_cmp<_Tp, _Up>{});, which basically checks to see if it is a pointer comparison, and if so, uses less<const volatile void*> to do the work, which in non constant evaluated contexts is return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;.
And to be consistent, we'd add all six comparator functors, both as a primary template as well as void and pointer specializations.
clang is functionally equivalent to what we do now. gcc does more work because of unusual architectures it supports, but I'm not sure that is applicable for us.
I guess I'm asking: is this worth doing (presumably following the gcc model)?
In C++17,
clamp(v, lo, hi)
usesoperator<
to do the comparison.In C++20 and beyond,
clamp(v, lo, hi)
usesstd::less{}
to do the comparison. I'm not sure why it changed (I cannot find the LWG issue), but I suspect this has something to do with clamping pointers.Should we change, and if so, should that change be dependent on the C++ version?
My answer to the above is yes and no.
The text was updated successfully, but these errors were encountered: