From 9a5dba9e0992d1fe77af0b6ec61dee22e25b1f3e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 15 Apr 2020 16:51:36 +0200 Subject: [PATCH] AK: Add MakeUnsigned helper template --- AK/StdLibExtras.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index e0fba83309..5a714fee2f 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -316,6 +316,60 @@ inline constexpr T&& forward(typename RemoveReference::Type&& param) noexcept return static_cast(param); } +template +struct MakeUnsigned { +}; + +template<> +struct MakeUnsigned { + typedef unsigned char type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned short type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned long type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned long long type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned char type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned short type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned long type; +}; + +template<> +struct MakeUnsigned { + typedef unsigned long long type; +}; + } using AK::ceil_div; @@ -324,6 +378,7 @@ using AK::Conditional; using AK::exchange; using AK::forward; using AK::IsSame; +using AK::MakeUnsigned; using AK::max; using AK::min; using AK::move;