@@ -63,6 +63,18 @@ class Timestamp {
63
63
*/
64
64
Timestamp (int64_t seconds, int32_t nanoseconds);
65
65
66
+ /* * Copy constructor, `Timestamp` is trivially copyable. */
67
+ Timestamp (const Timestamp& other) = default ;
68
+
69
+ /* * Move constructor, equivalent to copying. */
70
+ Timestamp (Timestamp&& other) = default ;
71
+
72
+ /* * Copy assignment operator, `Timestamp` is trivially copyable. */
73
+ Timestamp& operator =(const Timestamp& other) = default ;
74
+
75
+ /* * Move assignment operator, equivalent to copying. */
76
+ Timestamp& operator =(Timestamp&& other) = default ;
77
+
66
78
/* *
67
79
* Creates a new timestamp with the current date.
68
80
*
@@ -145,10 +157,16 @@ class Timestamp {
145
157
* Returns a string representation of this `Timestamp` for logging/debugging
146
158
* purposes.
147
159
*
148
- * Note : the exact string representation is unspecified and subject to change;
149
- * don't rely on the format of the string.
160
+ * @note : the exact string representation is unspecified and subject to
161
+ * change; don't rely on the format of the string.
150
162
*/
151
163
std::string ToString () const ;
164
+
165
+ /* *
166
+ * Outputs the string representation of this `Timestamp` to the given stream.
167
+ *
168
+ * @see `ToString()` for comments on the representation format.
169
+ */
152
170
friend std::ostream& operator <<(std::ostream& out,
153
171
const Timestamp& timestamp);
154
172
@@ -161,28 +179,34 @@ class Timestamp {
161
179
int32_t nanoseconds_ = 0 ;
162
180
};
163
181
182
+ /* * Checks whether `lhs` and `rhs` are in ascending order. */
164
183
inline bool operator <(const Timestamp& lhs, const Timestamp& rhs) {
165
184
return lhs.seconds () < rhs.seconds () ||
166
185
(lhs.seconds () == rhs.seconds () &&
167
186
lhs.nanoseconds () < rhs.nanoseconds ());
168
187
}
169
188
189
+ /* * Checks whether `lhs` and `rhs` are in descending order. */
170
190
inline bool operator >(const Timestamp& lhs, const Timestamp& rhs) {
171
191
return rhs < lhs;
172
192
}
173
193
194
+ /* * Checks whether `lhs` and `rhs` are in non-ascending order. */
174
195
inline bool operator >=(const Timestamp& lhs, const Timestamp& rhs) {
175
196
return !(lhs < rhs);
176
197
}
177
198
199
+ /* * Checks whether `lhs` and `rhs` are in non-descending order. */
178
200
inline bool operator <=(const Timestamp& lhs, const Timestamp& rhs) {
179
201
return !(lhs > rhs);
180
202
}
181
203
204
+ /* * Checks `lhs` and `rhs` for inequality. */
182
205
inline bool operator !=(const Timestamp& lhs, const Timestamp& rhs) {
183
206
return lhs < rhs || lhs > rhs;
184
207
}
185
208
209
+ /* * Checks `lhs` and `rhs` for equality. */
186
210
inline bool operator ==(const Timestamp& lhs, const Timestamp& rhs) {
187
211
return !(lhs != rhs);
188
212
}
@@ -213,10 +237,15 @@ std::chrono::time_point<Clock, Duration> Timestamp::ToTimePoint() const {
213
237
} // namespace firebase
214
238
215
239
namespace std {
240
+ /* * Convenience-only specialization of `std::hash`. */
216
241
template <>
217
242
struct hash <firebase::Timestamp> {
218
- // Note: specialization of `std::hash` is provided for convenience only. The
219
- // implementation is subject to change.
243
+ /* *
244
+ * Hashes the given `timestamp`.
245
+ *
246
+ * @note: specialization of `std::hash` is provided for convenience only. The
247
+ * implementation is subject to change.
248
+ */
220
249
size_t operator ()(const firebase::Timestamp& timestamp) const ;
221
250
};
222
251
} // namespace std
0 commit comments