Date: prev next · Thread: first prev next last
2020 Archives by date, by thread · List index


On Thursday 30 of January 2020, Kaganski Mike wrote:
Can the hypothetical make_signed function return a signed integer when
there's a bigger integer type exist,

 Yes.

and a struct with overloaded 
operator<=> when there's not, and that overloaded operator<=> would
check if contained unsigned value is greater than max value of its
signed argument, and return "contained unsigned is greater than passed
signed" in that case, otherwise fallback to "convert unsigned to signed
and compare normally" strategy? This would comply with the scope of the
function (which, as I understand it, to only be used in preparation to
comparison), always return mathematically correct result of comparison,
and allow all smaller types comparison to still be without overhead?
(But for 64-bit unsigned types, of course, it will introduce the
overhead. Will it be significant, though?)

 Not worth it. That'd be like doing error checking for every memory 
allocation - we also bother only with those few cases where it realistically 
can go wrong.

-- 
 Luboš Luňák
 l.lunak@collabora.com

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.