o3tl::make_unsigned
Stephan Bergmann
sbergman at redhat.com
Fri Jan 31 10:53:47 UTC 2020
On 31/01/2020 10:23, Kaganski Mike wrote:
> My take on this is https://gerrit.libreoffice.org/c/core/+/87762. I can
> see why it might be considered wrong and rejected (e.g., because
> overhead it brings is unacceptable; or because asserting on valid range
> is considered correct...) - but at least this would not (unless I made a
> programming error) give wrong results, not "I believe I will never meet
> values outside of this range".
If you want to follow down the "Unsigned considered harmful" path,
another option that may long-term prove more fruitful then that
o3tl::make_signed could be an o3tl::ssize mimicing C++20 std::ssize
(<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1227r2.html>
"P1227: Signed ssize() functions, unsigned size() functions (Revision
2)"; and being replaced by the true std::ssize once generally
available), and updating relevant places in the code to use that.
(Where occurrences of o3tl::make_unsigned would likely be good starting
points to hunt for such places. As discussed elsewhere in this thread,
that should get rid of many, if not most of the current uses of
o3tl::make_unsigned.)
More information about the LibreOffice
mailing list