summaryrefslogtreecommitdiff
path: root/absl/strings/internal/str_format/extension.h
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2022-08-31 12:29:19 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2022-08-31 12:30:01 -0700
commit6a262fdaddb6cd7df7ddc8472a1cc61cc64a01db (patch)
treecc11f9fd3f38a050846d6ef32a3273b363e6137e /absl/strings/internal/str_format/extension.h
parent72ec15a317a74cccf03a62f749f3ab28206be069 (diff)
Adds support for "%v" in absl::StrFormat and related functions for string-like types (support for other builtin types will follow in future changes). Rather than specifying %s for strings, users may specify %v and have the format specifier deduced. Notably, %v does not work for `const char*` because we cannot be certain if %s or %p was intended (nor can we be certain if the `const char*` was properly null-terminated). If you have a `const char*` you know is null-terminated and would like to work with %v, please wrap it in a `string_view` before using it.
PiperOrigin-RevId: 471321055 Change-Id: Ifbb50082d301baecc7edc277975f12e7ad3ecc8a
Diffstat (limited to 'absl/strings/internal/str_format/extension.h')
-rw-r--r--absl/strings/internal/str_format/extension.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/absl/strings/internal/str_format/extension.h b/absl/strings/internal/str_format/extension.h
index 55e8ac88..f8d98bf7 100644
--- a/absl/strings/internal/str_format/extension.h
+++ b/absl/strings/internal/str_format/extension.h
@@ -169,7 +169,7 @@ inline std::ostream& operator<<(std::ostream& os, Flags v) {
X_VAL(f) X_SEP X_VAL(F) X_SEP X_VAL(e) X_SEP X_VAL(E) X_SEP \
X_VAL(g) X_SEP X_VAL(G) X_SEP X_VAL(a) X_SEP X_VAL(A) X_SEP \
/* misc */ \
- X_VAL(n) X_SEP X_VAL(p)
+ X_VAL(n) X_SEP X_VAL(p) X_SEP X_VAL(v)
// clang-format on
// This type should not be referenced, it exists only to provide labels
@@ -191,7 +191,7 @@ struct FormatConversionCharInternal {
c, s, // text
d, i, o, u, x, X, // int
f, F, e, E, g, G, a, A, // float
- n, p, // misc
+ n, p, v, // misc
kNone
};
// clang-format on