Skip to content

Commit d7d871f

Browse files
committed
Protect generic type formatter against missing operator<<
This will be caught by the format string parser, this change is mostly to reduce noise on the command line.
1 parent 98c4a6d commit d7d871f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fly/types/string/detail/string_formatter.hpp

+8-5
Original file line numberDiff line numberDiff line change
@@ -335,13 +335,16 @@ inline void BasicStringFormatter<StringType, ParameterTypes...>::format_value(
335335
FormatSpecifier &&,
336336
const T &value)
337337
{
338-
static thread_local ostringstream_type s_stream;
338+
if constexpr (traits::OstreamTraits::template is_declared_v<T>)
339+
{
340+
static thread_local ostringstream_type s_stream;
339341

340-
s_stream << value;
341-
const auto formatted = s_stream.str();
342-
s_stream.str({});
342+
s_stream << value;
343+
const auto formatted = s_stream.str();
344+
s_stream.str({});
343345

344-
append_string(formatted, formatted.size());
346+
append_string(formatted, formatted.size());
347+
}
345348
}
346349

347350
//==================================================================================================

0 commit comments

Comments
 (0)