Mark all bool conversion operators as explicit

An explicit bool conversion operator will still be used implicitly
when an expression appears in "bool context", e.g., as the condition
in an if statement, or as argument to logical operators. The
`explicit` annotation prevents conversion in other contexts, e.g.,
converting both a and b to bool in an expression like `a == b`.

Bug: None
Change-Id: I79ef35b1ea831e6011ae472900375ae8a3e617ab
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250664
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35927}
This commit is contained in:
Niels Möller
2022-02-04 16:13:37 +01:00
committed by WebRTC LUCI CQ
parent 67a68d57bf
commit 325789c457
5 changed files with 7 additions and 5 deletions

View File

@ -36,7 +36,9 @@ class RtcEventLogParseStatus {
}
bool ok() const { return error_.empty(); }
ABSL_DEPRECATED("Use ok() instead") operator bool() const { return ok(); }
ABSL_DEPRECATED("Use ok() instead") explicit operator bool() const {
return ok();
}
std::string message() const { return error_; }