diff options
author | Marcin Kowalczyk <qrczak@google.com> | 2022-10-05 07:42:50 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2022-10-05 07:43:33 -0700 |
commit | b3162b1da62711c663d0025e2eabeb83fd1f2728 (patch) | |
tree | aa3eca5757799729c8302553b20196e0c0386f34 /absl/strings/str_cat.h | |
parent | d24156f63ca6d44a0dc05e260ad7810b2fcf3405 (diff) |
Make sinks provided to `AbslStringify()` usable with `absl::Format()`.
Such sinks must define ADL-callable `AbslFormatFlush()`. It can just forward to
`Append()`.
PiperOrigin-RevId: 479043790
Change-Id: I5d7d80ca1e17adf03b77726df8a52e2b4e9196ce
Diffstat (limited to 'absl/strings/str_cat.h')
-rw-r--r-- | absl/strings/str_cat.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/absl/strings/str_cat.h b/absl/strings/str_cat.h index 05728ab5..6ee88f14 100644 --- a/absl/strings/str_cat.h +++ b/absl/strings/str_cat.h @@ -85,6 +85,11 @@ class StringifySink { bool PutPaddedString(string_view v, int width, int precision, bool left); + // Support `absl::Format(&sink, format, args...)`. + friend void AbslFormatFlush(StringifySink* sink, absl::string_view v) { + sink->Append(v); + } + template <typename T> friend string_view ExtractStringification(StringifySink& sink, const T& v); |