numeric/endian: Add an EndianPacked std::formatter

Change-Id: Ie521dadc74093291d812e725d06fb87679214249
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/stdplus/numeric/endian.hpp b/include/stdplus/numeric/endian.hpp
index 0dcdfc6..c517ec4 100644
--- a/include/stdplus/numeric/endian.hpp
+++ b/include/stdplus/numeric/endian.hpp
@@ -3,6 +3,7 @@
 #include <bit>
 #include <cstddef>
 #include <cstdint>
+#include <format>
 #include <type_traits>
 
 namespace stdplus
@@ -231,3 +232,8 @@
 using uint64_unt = EndianPacked<std::uint64_t, std::endian::big>;
 
 } // namespace stdplus
+
+template <typename IntT, std::endian Endian, typename CharT>
+struct std::formatter<stdplus::EndianPacked<IntT, Endian>, CharT> :
+    std::formatter<IntT, CharT>
+{};
diff --git a/test/numeric/endian.cpp b/test/numeric/endian.cpp
index 8160753..e523565 100644
--- a/test/numeric/endian.cpp
+++ b/test/numeric/endian.cpp
@@ -54,4 +54,12 @@
     EXPECT_EQ(0x0f000000, l);
 }
 
+TEST(EndianPacked, Format)
+{
+    EXPECT_EQ(std::format("a {}\n", int32_t{-8456}),
+              std::format("a {}\n", int32_unt{-8456}));
+    EXPECT_EQ(std::format("a {:x}\n", uint32_t{13}),
+              std::format("a {:x}\n", uint32_ult{13}));
+}
+
 } // namespace stdplus