From 43afbfa120d51fe006e7c8ff3fc2370224d79da7 Mon Sep 17 00:00:00 2001 From: Nik Date: Sun, 9 Oct 2022 17:38:05 +0200 Subject: [PATCH] includes/type: Made size and float16 types more generic --- includes/type/float16.pat | 7 ++++--- includes/type/size.pat | 15 ++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/includes/type/float16.pat b/includes/type/float16.pat index 386712e..7b5a2e4 100644 --- a/includes/type/float16.pat +++ b/includes/type/float16.pat @@ -2,6 +2,7 @@ #include #include +#include namespace type { @@ -41,10 +42,10 @@ namespace type { result = (sign << 31) | ((exponent + (0x7F - 15)) << 23) | (mantissa << 13); } - U32ToFloatConverter converter; - converter.intValue = result; + std::mem::Reinterpreter converter; + converter.from = result; - return std::format("{}", converter.floatValue); + return std::format("{}", converter.to); }; } diff --git a/includes/type/size.pat b/includes/type/size.pat index d891910..63027e7 100644 --- a/includes/type/size.pat +++ b/includes/type/size.pat @@ -1,13 +1,14 @@ -#pragma once #include namespace type { - using Size8 = u8 [[format("type::impl::size_formatter")]]; - using Size16 = u16 [[format("type::impl::size_formatter")]]; - using Size32 = u32 [[format("type::impl::size_formatter")]]; - using Size64 = u64 [[format("type::impl::size_formatter")]]; - using Size128 = u128 [[format("type::impl::size_formatter")]]; + using Size = T [[format("type::impl::size_formatter")]]; + + using Size8 = Size; + using Size16 = Size; + using Size32 = Size; + using Size64 = Size; + using Size128 = Size; namespace impl { @@ -45,4 +46,4 @@ namespace type { } -} +} \ No newline at end of file