Skip to content

Commit 0546ba3

Browse files
committed
Replace IsNullable with a check that the type can be converted to bool
1 parent 62157bf commit 0546ba3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

llvm/include/llvm/Support/Casting.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,6 @@ template <typename To, typename From>
589589
// ValueIsPresent
590590
//===----------------------------------------------------------------------===//
591591

592-
template <typename T>
593-
constexpr bool IsNullable =
594-
std::is_pointer_v<T> || std::is_constructible_v<T, std::nullptr_t>;
595-
596592
/// ValueIsPresent provides a way to check if a value is, well, present. For
597593
/// pointers, this is the equivalent of checking against nullptr, for Optionals
598594
/// this is the equivalent of checking hasValue(). It also provides a method for
@@ -614,9 +610,9 @@ template <typename T> struct ValueIsPresent<std::optional<T>> {
614610
static inline decltype(auto) unwrapValue(std::optional<T> &t) { return *t; }
615611
};
616612

617-
// If something is "nullable" then we just cast it to bool to see if it exists.
613+
// Specialization for types convertible to bool.
618614
template <typename T>
619-
struct ValueIsPresent<T, std::enable_if_t<IsNullable<T>>> {
615+
struct ValueIsPresent<T, std::enable_if_t<std::is_constructible_v<bool, T>>> {
620616
using UnwrappedType = T;
621617
static inline bool isPresent(const T &t) { return static_cast<bool>(t); }
622618
static inline decltype(auto) unwrapValue(T &t) { return t; }

0 commit comments

Comments
 (0)