summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2021-07-30 20:14:06 +0000
committerAndreas Kling <kling@serenityos.org>2021-08-02 00:25:11 +0200
commit05c3755e62f5d83dd1a7f5bd8f4b5496fdc6aa1f (patch)
tree77cc49afd0ef260d2f52b53e7519995401c29a7d
parent0990c23fc31cd5e9e90b06697604dbd3150ea4fd (diff)
downloadserenity-05c3755e62f5d83dd1a7f5bd8f4b5496fdc6aa1f.zip
AK: Add formatters for BigEndian and LittleEndian
This allows printing out BigEndian and LittleEndian values without having to perform a static_cast first.
-rw-r--r--AK/Endian.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/AK/Endian.h b/AK/Endian.h
index 549e4f4869..adf3d82257 100644
--- a/AK/Endian.h
+++ b/AK/Endian.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/Platform.h>
@@ -134,6 +135,14 @@ private:
template<typename T>
using NetworkOrdered = BigEndian<T>;
+template<typename T>
+requires(HasFormatter<T>) struct Formatter<LittleEndian<T>> : Formatter<T> {
+};
+
+template<typename T>
+requires(HasFormatter<T>) struct Formatter<BigEndian<T>> : Formatter<T> {
+};
+
}
using AK::BigEndian;