include/basegfx/tuple/Tuple2D.hxx | 16 +++++----------- include/o3tl/concepts.hxx | 3 +++ 2 files changed, 8 insertions(+), 11 deletions(-)
New commits: commit 76b55ced15a85f2cd5da8e14a1543cd98c921357 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Jan 17 23:12:18 2025 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Jan 18 02:56:34 2025 +0100 basegfx: simplify template code by using concepts Change-Id: Ie5bff37dbc20253ec869b2e0e0379eb22e78f6d2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180415 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Jenkins diff --git a/include/basegfx/tuple/Tuple2D.hxx b/include/basegfx/tuple/Tuple2D.hxx index 7494b4d1b13a..09acb035620c 100644 --- a/include/basegfx/tuple/Tuple2D.hxx +++ b/include/basegfx/tuple/Tuple2D.hxx @@ -10,6 +10,7 @@ #pragma once +#include <o3tl/concepts.hxx> #include <basegfx/utils/common.hxx> #include <basegfx/numeric/ftools.hxx> @@ -68,26 +69,19 @@ public: // comparators with tolerance - template <typename T = TYPE, std::enable_if_t<std::is_integral_v<T>, int> = 0> - bool equal(const Tuple2D<TYPE>& rTup) const + template <o3tl::integral T = TYPE> bool equal(const Tuple2D<TYPE>& rTup) const { return mnX == rTup.mnX && mnY == rTup.mnY; } - template <typename T = TYPE, std::enable_if_t<std::is_floating_point_v<T>, int> = 0> - bool equal(const Tuple2D<TYPE>& rTup) const + template <o3tl::floating_point T = TYPE> bool equal(const Tuple2D<TYPE>& rTup) const { return this == &rTup || (fTools::equal(mnX, rTup.mnX) && fTools::equal(mnY, rTup.mnY)); } - template <typename T = TYPE, std::enable_if_t<std::is_integral_v<T>, int> = 0> - bool equalZero() const - { - return mnX == 0 && mnY == 0; - } + template <o3tl::integral T = TYPE> bool equalZero() const { return mnX == 0 && mnY == 0; } - template <typename T = TYPE, std::enable_if_t<std::is_floating_point_v<T>, int> = 0> - bool equalZero() const + template <o3tl::floating_point T = TYPE> bool equalZero() const { return fTools::equalZero(mnX) && fTools::equalZero(mnY); } diff --git a/include/o3tl/concepts.hxx b/include/o3tl/concepts.hxx index 261d063ebca2..f47aef5f256d 100644 --- a/include/o3tl/concepts.hxx +++ b/include/o3tl/concepts.hxx @@ -23,6 +23,7 @@ namespace o3tl using std::integral; using std::signed_integral; using std::unsigned_integral; +using std::floating_point; } #else @@ -38,6 +39,8 @@ template <typename T> concept integral = std::is_integral_v<T>; template <typename T> concept signed_integral = integral<T>&& std::is_signed_v<T>; template <typename T> concept unsigned_integral = integral<T> && !signed_integral<T>; + +template <typename T> concept floating_point = std::is_floating_point_v<T>; } #endif