@@ -62,11 +62,20 @@ struct FormatChoice<5> {};
62
62
* formatting of the value as an unsigned integer.
63
63
* * Otherwise the value is interpreted as anything absl::AlphaNum accepts.
64
64
*/
65
- class FormatArg : public absl ::AlphaNum {
65
+ class FormatArg final : public absl::AlphaNum {
66
66
public:
67
67
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 >{}} {
70
79
}
71
80
72
81
private:
@@ -79,7 +88,9 @@ class FormatArg : public absl::AlphaNum {
79
88
*/
80
89
template <typename T,
81
90
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 >)
83
94
: AlphaNum(bool_value ? " true" : " false" ) {
84
95
}
85
96
@@ -90,15 +101,19 @@ class FormatArg : public absl::AlphaNum {
90
101
template <
91
102
typename T,
92
103
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 >)
94
107
: AlphaNum(MakeStringView([object description])) {
95
108
}
96
109
97
110
/* *
98
111
* Creates a FormatArg from any Objective-C Class type. Objective-C Class
99
112
* types are a special struct that aren't of a type derived from NSObject.
100
113
*/
101
- FormatArg (Class object, internal::FormatChoice<1 >)
114
+ FormatArg (Class object,
115
+ absl::strings_internal::StringifySink&&,
116
+ internal::FormatChoice<1 >)
102
117
: AlphaNum(MakeStringView(NSStringFromClass(object))) {
103
118
}
104
119
#endif
@@ -108,15 +123,20 @@ class FormatArg : public absl::AlphaNum {
108
123
* handled specially to avoid ambiguity with generic pointers, which are
109
124
* handled differently.
110
125
*/
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" ) {
112
130
}
113
131
114
132
/* *
115
133
* Creates a FormatArg from a character string literal. This is
116
134
* handled specially to avoid ambiguity with generic pointers, which are
117
135
* handled differently.
118
136
*/
119
- FormatArg (const char * string_value, internal::FormatChoice<3 >)
137
+ FormatArg (const char * string_value,
138
+ absl::strings_internal::StringifySink&&,
139
+ internal::FormatChoice<3 >)
120
140
: AlphaNum(string_value == nullptr ? " null" : string_value) {
121
141
}
122
142
@@ -125,16 +145,21 @@ class FormatArg : public absl::AlphaNum {
125
145
* hexadecimal integer literal.
126
146
*/
127
147
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)) {
130
153
}
131
154
132
155
/* *
133
156
* As a final fallback, creates a FormatArg from any type of value that
134
157
* absl::AlphaNum accepts.
135
158
*/
136
159
template <typename T>
137
- FormatArg (T&& value, internal::FormatChoice<5 >)
160
+ FormatArg (T&& value,
161
+ absl::strings_internal::StringifySink&&,
162
+ internal::FormatChoice<5 >)
138
163
: AlphaNum(std::forward<T>(value)) {
139
164
}
140
165
};
0 commit comments