Make a few more operator bool explicit.
Bug: dawn:2489
Change-Id: I476a86ad45c392e43c6d1a14478ece6222fe34d0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/183122
Reviewed-by: Ben Clayton <bclayton@google.com>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/ChainUtils.h b/src/dawn/native/ChainUtils.h
index ffdca49..a22ceeb 100644
--- a/src/dawn/native/ChainUtils.h
+++ b/src/dawn/native/ChainUtils.h
@@ -99,7 +99,7 @@
UnpackedPtr() : mStruct(nullptr) {}
- operator bool() const { return mStruct != nullptr; }
+ explicit operator bool() const { return mStruct != nullptr; }
PtrType operator->() const { return mStruct; }
PtrType operator*() const { return mStruct; }
diff --git a/src/dawn/node/Module.cpp b/src/dawn/node/Module.cpp
index 1061c8b..0ac36d0 100644
--- a/src/dawn/node/Module.cpp
+++ b/src/dawn/node/Module.cpp
@@ -50,8 +50,7 @@
const auto& env = info.Env();
std::tuple<std::vector<std::string>> args;
- auto res = wgpu::interop::FromJS(info, args);
- if (res != wgpu::interop::Success) {
+ if (auto res = wgpu::interop::FromJS(info, args); !res) {
Napi::Error::New(env, res.error).ThrowAsJavaScriptException();
return env.Undefined();
}
diff --git a/src/dawn/node/interop/Core.h b/src/dawn/node/interop/Core.h
index 1352e8b..b9b4ea8 100644
--- a/src/dawn/node/interop/Core.h
+++ b/src/dawn/node/interop/Core.h
@@ -121,7 +121,7 @@
// conversion
struct [[nodiscard]] Result {
// Returns true if the operation succeeded, false if there was an error
- inline operator bool() const { return error.empty(); }
+ inline explicit operator bool() const { return error.empty(); }
// If Result is an error, then a new Error is returned with the
// stringified values append to the error message.