From e90ecdda48083b22b61a0690c00e27b1aa0c38ec Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 23 May 2020 12:39:51 +0200 Subject: [PATCH] AK: Add MakeSigned helper template --- AK/StdLibExtras.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index 0d95585aa0..d94b6f754a 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -362,6 +362,60 @@ struct MakeUnsigned { typedef unsigned long long type; }; +template +struct MakeSigned { +}; + +template<> +struct MakeSigned { + typedef char type; +}; + +template<> +struct MakeSigned { + typedef short type; +}; + +template<> +struct MakeSigned { + typedef int type; +}; + +template<> +struct MakeSigned { + typedef long type; +}; + +template<> +struct MakeSigned { + typedef long long type; +}; + +template<> +struct MakeSigned { + typedef char type; +}; + +template<> +struct MakeSigned { + typedef short type; +}; + +template<> +struct MakeSigned { + typedef int type; +}; + +template<> +struct MakeSigned { + typedef long type; +}; + +template<> +struct MakeSigned { + typedef long long type; +}; + template inline constexpr T exchange(T& slot, U&& value) { @@ -378,6 +432,7 @@ using AK::Conditional; using AK::exchange; using AK::forward; using AK::IsSame; +using AK::MakeSigned; using AK::MakeUnsigned; using AK::max; using AK::min;