We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e94d628 commit 09c1f8fCopy full SHA for 09c1f8f
modules/compiler/multi_llvm/include/multi_llvm/optional_helper.h
@@ -24,9 +24,7 @@
24
#include <llvm/ADT/Optional.h>
25
#endif
26
27
-#if (LLVM_VERSION_MAJOR >= 16)
28
#include <optional>
29
-#endif
30
31
namespace multi_llvm {
32
@@ -64,6 +62,13 @@ class Optional : public llvm::Optional<T> {
64
62
inline constexpr bool has_value() const {
65
63
return llvm::Optional<T>::hasValue();
66
}
+
+ // Provide implicit conversions to the future proof std::optional.
67
+ inline constexpr operator std::optional<T>() const {
68
+ return llvm::Optional<T>::hasValue()
69
+ ? std::optional<T>(llvm::Optional<T>::getValue())
70
+ : std::nullopt;
71
+ }
72
};
73
74
0 commit comments