Ver código fonte

AK: Add special formatter for char.

When we format a character we want to put the ascii value and not the
decimal value. The old behaviour can be obtained with '{:d}'.
asynts 4 anos atrás
pai
commit
aa283d235a
1 arquivos alterados com 8 adições e 0 exclusões
  1. 8 0
      AK/Format.h

+ 8 - 0
AK/Format.h

@@ -280,6 +280,14 @@ struct Formatter<T*> : StandardFormatter {
     }
 };
 
+template<>
+struct Formatter<char> : Formatter<StringView> {
+    void format(TypeErasedFormatParams& params, FormatBuilder& builder, char value)
+    {
+        Formatter<StringView>::format(params, builder, { &value, 1 });
+    }
+};
+
 template<>
 struct Formatter<bool> : StandardFormatter {
     void format(TypeErasedFormatParams&, FormatBuilder&, bool value);