@@ -62,11 +62,20 @@ struct FormatChoice<5> {};
6262 * formatting of the value as an unsigned integer.
6363 * * Otherwise the value is interpreted as anything absl::AlphaNum accepts.
6464 */
65- class FormatArg : public absl ::AlphaNum {
65+ class FormatArg final : public absl::AlphaNum {
6666 public:
6767 template <typename T>
68- FormatArg (T&& value) // NOLINT(runtime/explicit)
69- : FormatArg{std::forward<T>(value), internal::FormatChoice<0 >{}} {
68+ FormatArg (
69+ T&& value,
70+ // TODO(b/388888512) Remove the usage of StringifySink since it is not
71+ // part of absl's public API. Moreover, subclassing AlphaNum is not
72+ // supported either, so find a way to do this without these two caveats.
73+ // See https://github.com/firebase/firebase-ios-sdk/pull/14331 for a
74+ // partial proposal.
75+ absl::strings_internal::StringifySink&& sink =
76+ {}) // NOLINT(runtime/explicit)
77+ : FormatArg{std::forward<T>(value), std::move (sink),
78+ internal::FormatChoice<0 >{}} {
7079 }
7180
7281 private:
@@ -79,7 +88,9 @@ class FormatArg : public absl::AlphaNum {
7988 */
8089 template <typename T,
8190 typename = typename std::enable_if<std::is_same<bool , T>{}>::type>
82- FormatArg (T bool_value, internal::FormatChoice<0 >)
91+ FormatArg (T bool_value,
92+ absl::strings_internal::StringifySink&&,
93+ internal::FormatChoice<0 >)
8394 : AlphaNum(bool_value ? " true" : " false" ) {
8495 }
8596
@@ -90,15 +101,19 @@ class FormatArg : public absl::AlphaNum {
90101 template <
91102 typename T,
92103 typename = typename std::enable_if<objc::is_objc_pointer<T>{}>::type>
93- FormatArg (T object, internal::FormatChoice<1 >)
104+ FormatArg (T object,
105+ absl::strings_internal::StringifySink&&,
106+ internal::FormatChoice<1 >)
94107 : AlphaNum(MakeStringView([object description])) {
95108 }
96109
97110 /* *
98111 * Creates a FormatArg from any Objective-C Class type. Objective-C Class
99112 * types are a special struct that aren't of a type derived from NSObject.
100113 */
101- FormatArg (Class object, internal::FormatChoice<1 >)
114+ FormatArg (Class object,
115+ absl::strings_internal::StringifySink&&,
116+ internal::FormatChoice<1 >)
102117 : AlphaNum(MakeStringView(NSStringFromClass(object))) {
103118 }
104119#endif
@@ -108,15 +123,20 @@ class FormatArg : public absl::AlphaNum {
108123 * handled specially to avoid ambiguity with generic pointers, which are
109124 * handled differently.
110125 */
111- FormatArg (std::nullptr_t , internal::FormatChoice<2 >) : AlphaNum(" null" ) {
126+ FormatArg (std::nullptr_t ,
127+ absl::strings_internal::StringifySink&&,
128+ internal::FormatChoice<2 >)
129+ : AlphaNum(" null" ) {
112130 }
113131
114132 /* *
115133 * Creates a FormatArg from a character string literal. This is
116134 * handled specially to avoid ambiguity with generic pointers, which are
117135 * handled differently.
118136 */
119- FormatArg (const char * string_value, internal::FormatChoice<3 >)
137+ FormatArg (const char * string_value,
138+ absl::strings_internal::StringifySink&&,
139+ internal::FormatChoice<3 >)
120140 : AlphaNum(string_value == nullptr ? " null" : string_value) {
121141 }
122142
@@ -125,16 +145,21 @@ class FormatArg : public absl::AlphaNum {
125145 * hexadecimal integer literal.
126146 */
127147 template <typename T>
128- FormatArg (T* pointer_value, internal::FormatChoice<4 >)
129- : AlphaNum(absl::Hex(reinterpret_cast <uintptr_t >(pointer_value))) {
148+ FormatArg (T* pointer_value,
149+ absl::strings_internal::StringifySink&& sink,
150+ internal::FormatChoice<4 >)
151+ : AlphaNum(absl::Hex(reinterpret_cast <uintptr_t >(pointer_value)),
152+ std::move (sink)) {
130153 }
131154
132155 /* *
133156 * As a final fallback, creates a FormatArg from any type of value that
134157 * absl::AlphaNum accepts.
135158 */
136159 template <typename T>
137- FormatArg (T&& value, internal::FormatChoice<5 >)
160+ FormatArg (T&& value,
161+ absl::strings_internal::StringifySink&&,
162+ internal::FormatChoice<5 >)
138163 : AlphaNum(std::forward<T>(value)) {
139164 }
140165};
0 commit comments