1
0
forked from mirrors/0ad

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.

This was SVN commit r16179.
This commit is contained in:
Ykkrosh
2015-01-22 20:27:34 +00:00
parent 8875ae9cdf
commit 9c8798b592
+5
View File
@@ -706,12 +706,17 @@ public:
MakeArg(void *value) { type = POINTER; pointer_value = value; }
MakeArg(const void *value) { type = POINTER; pointer_value = value; }
#if 0
// WFG: Removed this because otherwise you can pass a CStr8 or an enum etc
// into fmt::sprintf, and it will be interpreted as a CUSTOM type and then
// will throw an exception at runtime, which is terrible behaviour.
template <typename T>
MakeArg(const T &value) {
type = CUSTOM;
custom.value = &value;
custom.format = &format_custom_arg<T>;
}
#endif
};
#define FMT_DISPATCH(call) static_cast<Impl*>(this)->call