From 3aa5db5b1cfe56266b414633dc87ca0be6043aa5 Mon Sep 17 00:00:00 2001 From: q66 Date: Mon, 20 Feb 2017 18:31:08 +0100 Subject: [PATCH] do not implicitly to_string as a fallback in format --- ostd/format.hh | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/ostd/format.hh b/ostd/format.hh index 04e75f6..c2001c1 100644 --- a/ostd/format.hh +++ b/ostd/format.hh @@ -173,17 +173,6 @@ namespace detail { } } - /* fallback test for whether a value can be converted to string */ - template - static std::true_type test_fmt_tostr( - decltype(ostd::to_string{}(std::declval())) * - ); - template - static std::false_type test_fmt_tostr(...); - - template - constexpr bool fmt_tostr_test = decltype(test_fmt_tostr(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) { - if (spec() != 's') { - throw format_error{"custom objects need the '%s' spec"}; - } - write_val(writer, false, ostd::to_string{}(val)); - return; - } /* we ran out of options, failure */ throw format_error{"the value cannot be formatted"}; }