do not implicitly to_string as a fallback in format

master
Daniel Kolesa 2017-02-20 18:31:08 +01:00
parent 5a76f29dea
commit 3aa5db5b1c
1 changed files with 0 additions and 19 deletions

View File

@ -173,17 +173,6 @@ namespace detail {
}
}
/* fallback test for whether a value can be converted to string */
template<typename T>
static std::true_type test_fmt_tostr(
decltype(ostd::to_string<T>{}(std::declval<T>())) *
);
template<typename>
static std::false_type test_fmt_tostr(...);
template<typename T>
constexpr bool fmt_tostr_test = decltype(test_fmt_tostr<T>(0))::value;
/* ugly ass check for whether a type is tuple-like, like tuple itself,
* pair, array, possibly other types added later or overridden...
*/
@ -734,14 +723,6 @@ private:
write_float(writer, val);
return;
}
/* stuff that can be to_string'd, worst reliable case, allocates */
if constexpr(detail::fmt_tostr_test<T>) {
if (spec() != 's') {
throw format_error{"custom objects need the '%s' spec"};
}
write_val(writer, false, ostd::to_string<T>{}(val));
return;
}
/* we ran out of options, failure */
throw format_error{"the value cannot be formatted"};
}