diff --git a/cppu/source/uno/eq.hxx b/cppu/source/uno/eq.hxx index 60a372886776..b3fb5c4c5a5d 100644 --- a/cppu/source/uno/eq.hxx +++ b/cppu/source/uno/eq.hxx @@ -20,8 +20,8 @@ #include #include +#include -#include #include #include @@ -295,25 +295,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -326,25 +326,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -357,25 +357,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -388,25 +388,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -419,25 +419,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -450,25 +450,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: return (static_cast(*static_cast(pDest)) == *static_cast(pSource)); @@ -481,25 +481,25 @@ inline bool _equalData( switch (eSourceTypeClass) { case typelib_TypeClass_BYTE: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_SHORT: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_LONG: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_UNSIGNED_HYPER: - return o3tl::cmp_equal( + return std::cmp_equal( *static_cast(pDest), *static_cast(pSource)); case typelib_TypeClass_FLOAT: if (::floor( *static_cast(pSource) ) != *static_cast(pSource) || *static_cast(pSource) < 0) diff --git a/include/o3tl/intcmp.hxx b/include/o3tl/intcmp.hxx index dbc10d9052b0..dcfefae8531f 100644 --- a/include/o3tl/intcmp.hxx +++ b/include/o3tl/intcmp.hxx @@ -11,82 +11,10 @@ #include -#include #include -#include - namespace o3tl { -// An approximation of the C++20 integer comparison functions -// ( "Safe integral -// comparisons"), still missing from LLVM 12 libc++: -#if defined __cpp_lib_integer_comparison_functions - -using std::cmp_equal; -using std::cmp_not_equal; -using std::cmp_less; -using std::cmp_greater; -using std::cmp_less_equal; -using std::cmp_greater_equal; - -#else - -template constexpr bool cmp_equal(T1 value1, T2 value2) noexcept -{ - // coverity[same_on_both_sides: FALSE] - if constexpr (std::is_signed_v == std::is_signed_v) - { - return value1 == value2; - } - else if constexpr (std::is_signed_v) - { - return value1 >= 0 && o3tl::make_unsigned(value1) == value2; - } - else - { - return value2 >= 0 && value1 == o3tl::make_unsigned(value2); - } -} - -template constexpr bool cmp_not_equal(T1 value1, T2 value2) noexcept -{ - return !cmp_equal(value1, value2); -} - -template constexpr bool cmp_less(T1 value1, T2 value2) noexcept -{ - if constexpr (std::is_signed_v == std::is_signed_v) - { - return value1 < value2; - } - else if constexpr (std::is_signed_v) - { - return value1 < 0 || o3tl::make_unsigned(value1) < value2; - } - else - { - return value2 >= 0 && value1 < o3tl::make_unsigned(value2); - } -} - -template constexpr bool cmp_greater(T1 value1, T2 value2) noexcept -{ - return cmp_less(value2, value1); -} - -template constexpr bool cmp_less_equal(T1 value1, T2 value2) noexcept -{ - return !cmp_greater(value1, value2); -} - -template constexpr bool cmp_greater_equal(T1 value1, T2 value2) noexcept -{ - return !cmp_less(value1, value2); -} - -#endif - // A convenient operator syntax around the standard integer comparison functions: template struct IntCmp { @@ -100,32 +28,32 @@ template struct IntCmp template constexpr bool operator==(IntCmp value1, IntCmp value2) { - return o3tl::cmp_equal(value1.value, value2.value); + return std::cmp_equal(value1.value, value2.value); } template constexpr bool operator!=(IntCmp value1, IntCmp value2) { - return o3tl::cmp_not_equal(value1.value, value2.value); + return std::cmp_not_equal(value1.value, value2.value); } template constexpr bool operator<(IntCmp value1, IntCmp value2) { - return o3tl::cmp_less(value1.value, value2.value); + return std::cmp_less(value1.value, value2.value); } template constexpr bool operator>(IntCmp value1, IntCmp value2) { - return o3tl::cmp_greater(value1.value, value2.value); + return std::cmp_greater(value1.value, value2.value); } template constexpr bool operator<=(IntCmp value1, IntCmp value2) { - return o3tl::cmp_less_equal(value1.value, value2.value); + return std::cmp_less_equal(value1.value, value2.value); } template constexpr bool operator>=(IntCmp value1, IntCmp value2) { - return o3tl::cmp_greater_equal(value1.value, value2.value); + return std::cmp_greater_equal(value1.value, value2.value); } } diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx index d24a0fed3465..dcc19d3b6ddd 100644 --- a/sal/rtl/ustring.cxx +++ b/sal/rtl/ustring.cxx @@ -22,9 +22,9 @@ #include #include #include +#include #include -#include #include #include #include @@ -736,8 +736,8 @@ sal_uInt32 SAL_CALL rtl_uString_iterateCodePoints( assert(string != nullptr && indexUtf16 != nullptr); assert( *indexUtf16 >= 0 - && o3tl::cmp_less_equal(*indexUtf16, std::numeric_limits::max())); - // using o3tl::cmp_less_equal nicely avoids potential + && std::cmp_less_equal(*indexUtf16, std::numeric_limits::max())); + // using std::cmp_less_equal nicely avoids potential // -Wtautological-constant-out-of-range-compare auto const cp = o3tl::iterateCodePoints( std::u16string_view(string->buffer, string->length), indexUtf16, incrementCodePoints);