Ticket #3011: 0005-cppformat-Remove-support-for-CUSTOM-types.patch

File 0005-cppformat-Remove-support-for-CUSTOM-types.patch, 1.4 KB (added by Philip Taylor, 9 years ago)
  • source/third_party/cppformat/format.h

    From 08304da099d0e162088a6c0f2eae61d03f64ec8d Mon Sep 17 00:00:00 2001
    From: Philip Taylor <philip@zaynar.co.uk>
    Date: Tue, 20 Jan 2015 23:16:07 +0000
    Subject: [PATCH 05/13] cppformat: Remove support for CUSTOM types.
    
    These cause a lot of type-safety trouble - unsupported types passed into fmt::sprintf (like CStr or enums) will be accepted at compile time, but trigger an exception at runtime. Remove them, so we'll get either an implicit conversion to a supported type, or a compile-time error.
    ---
     source/third_party/cppformat/format.h | 5 +++++
     1 file changed, 5 insertions(+)
    
    diff --git a/source/third_party/cppformat/format.h b/source/third_party/cppformat/format.h
    index b3c93eb..01452d0 100644
    a b public:  
    706706  MakeArg(void *value) { type = POINTER; pointer_value = value; }
    707707  MakeArg(const void *value) { type = POINTER; pointer_value = value; }
    708708
     709#if 0
     710  // WFG: Removed this because otherwise you can pass a CStr8 or an enum etc
     711  // into fmt::sprintf, and it will be interpreted as a CUSTOM type and then
     712  // will throw an exception at runtime, which is terrible behaviour.
    709713  template <typename T>
    710714  MakeArg(const T &value) {
    711715    type = CUSTOM;
    712716    custom.value = &value;
    713717    custom.format = &format_custom_arg<T>;
    714718  }
     719#endif
    715720};
    716721
    717722#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call