瀏覽代碼

AK: Add a formatter for OwnPtr<T>

This formatter just prints the object out as a pointer.
Ali Mohammad Pur 1 年之前
父節點
當前提交
58fc901578
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      AK/OwnPtr.h

+ 7 - 0
AK/OwnPtr.h

@@ -200,6 +200,13 @@ struct Traits<OwnPtr<T>> : public DefaultTraits<OwnPtr<T>> {
     static bool equals(OwnPtr<T> const& a, OwnPtr<T> const& b) { return a.ptr() == b.ptr(); }
     static bool equals(OwnPtr<T> const& a, OwnPtr<T> const& b) { return a.ptr() == b.ptr(); }
 };
 };
 
 
+template<typename T>
+struct Formatter<OwnPtr<T>> : Formatter<T*> {
+    ErrorOr<void> format(FormatBuilder& builder, OwnPtr<T> const& value)
+    {
+        return Formatter<T*>::format(builder, value.ptr());
+    }
+};
 }
 }
 
 
 #if USING_AK_GLOBALLY
 #if USING_AK_GLOBALLY