[dawn][native] Add UnpackedPtr::Has

This is a shorthand for ::Get() == nullptr and conveys the semantic more
precisely.

Bug: 435251399
Change-Id: I3e0dba137390ffe70a078d7f55ab1cda328b7c06
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/256474
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/src/dawn/native/ChainUtils.h b/src/dawn/native/ChainUtils.h
index 7594137..75519a6 100644
--- a/src/dawn/native/ChainUtils.h
+++ b/src/dawn/native/ChainUtils.h
@@ -110,6 +110,8 @@
 
     template <typename In>
     auto Get() const;
+    template <typename In>
+    bool Has() const;
 
     // Validation functions. See implementations of these below for usage, details, and examples.
     template <typename... Branches>
@@ -247,6 +249,12 @@
 }
 
 template <typename T>
+template <typename In>
+bool UnpackedPtr<T>::Has() const {
+    return std::get<typename detail::PtrTypeFor<UnpackedPtr<T>, In>::Type>(mUnpacked) != nullptr;
+}
+
+template <typename T>
 bool UnpackedPtr<T>::Empty() const {
     return mBitset.none();
 }