summaryrefslogtreecommitdiff
path: root/AK/StringBuilder.h
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2023-01-13 02:19:40 +0000
committerLinus Groh <mail@linusgroh.de>2023-01-13 21:09:26 +0000
commit9a120d7243ea28ac61a8bda477910ee2c7ea159b (patch)
tree0acd906b498f83bd871d0eb4035ecf81218addb8 /AK/StringBuilder.h
parent13883753109ae1253d0f36a5cc9e4a45b3084c12 (diff)
downloadserenity-9a120d7243ea28ac61a8bda477910ee2c7ea159b.zip
AK: Add support for "debug only" formatters
These are formatters that can only be used with debug print functions, such as dbgln(). Currently this is limited to Formatter<ErrorOr<T>>. With this you can still debug log ErrorOr values (good for debugging), but trying to use them in any String::formatted() call will fail (which prevents .to_string() errors with the new failable strings being ignored). You make a formatter debug only by adding a constexpr method like: static constexpr bool is_debug_only() { return true; }
Diffstat (limited to 'AK/StringBuilder.h')
-rw-r--r--AK/StringBuilder.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/AK/StringBuilder.h b/AK/StringBuilder.h
index 5e28ef0300..98299ea86b 100644
--- a/AK/StringBuilder.h
+++ b/AK/StringBuilder.h
@@ -33,7 +33,7 @@ public:
template<typename... Parameters>
ErrorOr<void> try_appendff(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
{
- VariadicFormatParams variadic_format_params { parameters... };
+ VariadicFormatParams<AllowDebugOnlyFormatters::No, Parameters...> variadic_format_params { parameters... };
return vformat(*this, fmtstr.view(), variadic_format_params);
}
ErrorOr<void> try_append(char const*, size_t);
@@ -57,7 +57,7 @@ public:
template<typename... Parameters>
void appendff(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
{
- VariadicFormatParams variadic_format_params { parameters... };
+ VariadicFormatParams<AllowDebugOnlyFormatters::No, Parameters...> variadic_format_params { parameters... };
MUST(vformat(*this, fmtstr.view(), variadic_format_params));
}