Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: webrtc/base/optional.h

Issue 1813763005: Updated structures and functions for setting the max bitrate limit to take rtc::Optional<int> Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: More code review feedback Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/base/optional.h
diff --git a/webrtc/base/optional.h b/webrtc/base/optional.h
index b8071e635876b1b42b4bb7d6b6c10b417d25ad7e..5c89c9c22f5e61abbf4fa1c5e4c3a0babb950972 100644
--- a/webrtc/base/optional.h
+++ b/webrtc/base/optional.h
@@ -13,7 +13,7 @@
#include <algorithm>
#include <utility>
-
+#include <ostream>
#include "webrtc/base/checks.h"
namespace rtc {
@@ -134,6 +134,18 @@ class Optional final {
bool has_value_;
};
+// Defines the operator to write Optional<T> to an output stream. Allows for
+// simplified logging of optional parameters.
+template <typename T>
+std::ostream& operator<<(std::ostream& stream, rtc::Optional<T> value) {
kwiberg-webrtc 2016/03/29 11:30:45 Second argument should be const ref to avoid copyi
skvlad 2016/03/30 19:40:44 Done.
+ if (value) {
+ stream << *value;
+ } else {
+ stream << "<not set>";
+ }
+ return stream;
+}
+
} // namespace rtc
#endif // WEBRTC_BASE_OPTIONAL_H_

Powered by Google App Engine
This is Rietveld 408576698