From eb9fe3c46cdbf8801e9427bf61d1130dcab85013 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Tue, 19 Sep 2023 10:08:28 +0200 Subject: [PATCH] fix: mark fmt::streamed() as constexpr Because it's just performing a very basic type conversion that can be done at constexpr time. My use case simultaneously creates a `fmt::basic_format_string>` instance and performs `some_type_conversion(args)...`. `some_type_conversion` optionally applies `fmt::streamed(arg)` to a subset of types. This needs to be `constexpr` because `basic_format_string`'s constructor is `consteval`. --- include/fmt/ostream.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index a112fe7ba970..e5ae9e18bb0d 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -140,7 +140,7 @@ struct formatter, Char> \endrst */ template -auto streamed(const T& value) -> detail::streamed_view { +constexpr auto streamed(const T& value) -> detail::streamed_view { return {value}; }