[llvm] [ADT] Specialize ValueIsPresent for PointerUnion (PR #121847)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 16:23:54 PST 2025


================
@@ -614,12 +610,11 @@ template <typename T> struct ValueIsPresent<std::optional<T>> {
   static inline decltype(auto) unwrapValue(std::optional<T> &t) { return *t; }
 };
 
-// If something is "nullable" then we just compare it to nullptr to see if it
-// exists.
+// Specialization for types convertible to bool.
 template <typename T>
-struct ValueIsPresent<T, std::enable_if_t<IsNullable<T>>> {
+struct ValueIsPresent<T, std::enable_if_t<std::is_constructible_v<bool, T>>> {
----------------
kuhar wrote:

Should we keep the check that T can be constructed with `nullptr`? There are types that can be cast to bool but are not pointer-like.

https://github.com/llvm/llvm-project/pull/121847


More information about the llvm-commits mailing list