|
@@ -69,18 +69,20 @@ public:
|
|
|
|
|
|
bool hasValue() const noexcept { return hasVal; }
|
|
bool hasValue() const noexcept { return hasVal; }
|
|
|
|
|
|
- T &getValue() & noexcept {
|
|
|
|
|
|
+ T &getValue() LLVM_LVALUE_FUNCTION noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return value;
|
|
return value;
|
|
}
|
|
}
|
|
- T const &getValue() const & noexcept {
|
|
|
|
|
|
+ T const &getValue() const LLVM_LVALUE_FUNCTION noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return value;
|
|
return value;
|
|
}
|
|
}
|
|
|
|
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
|
|
T &&getValue() && noexcept {
|
|
T &&getValue() && noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return std::move(value);
|
|
return std::move(value);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
template <class... Args> void emplace(Args &&... args) {
|
|
template <class... Args> void emplace(Args &&... args) {
|
|
reset();
|
|
reset();
|
|
@@ -167,19 +169,20 @@ public:
|
|
|
|
|
|
bool hasValue() const noexcept { return hasVal; }
|
|
bool hasValue() const noexcept { return hasVal; }
|
|
|
|
|
|
- T &getValue() & noexcept {
|
|
|
|
|
|
+ T &getValue() LLVM_LVALUE_FUNCTION noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return value;
|
|
return value;
|
|
}
|
|
}
|
|
- T const &getValue() const & noexcept {
|
|
|
|
|
|
+ T const &getValue() const LLVM_LVALUE_FUNCTION noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return value;
|
|
return value;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
|
|
T &&getValue() && noexcept {
|
|
T &&getValue() && noexcept {
|
|
assert(hasVal);
|
|
assert(hasVal);
|
|
return std::move(value);
|
|
return std::move(value);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
|
|
|
|
template <class... Args> void emplace(Args &&... args) {
|
|
template <class... Args> void emplace(Args &&... args) {
|
|
reset();
|
|
reset();
|
|
@@ -249,21 +252,22 @@ public:
|
|
|
|
|
|
const T *getPointer() const { return &Storage.getValue(); }
|
|
const T *getPointer() const { return &Storage.getValue(); }
|
|
T *getPointer() { return &Storage.getValue(); }
|
|
T *getPointer() { return &Storage.getValue(); }
|
|
- const T &getValue() const & { return Storage.getValue(); }
|
|
|
|
- T &getValue() & { return Storage.getValue(); }
|
|
|
|
|
|
+ const T &getValue() const LLVM_LVALUE_FUNCTION { return Storage.getValue(); }
|
|
|
|
+ T &getValue() LLVM_LVALUE_FUNCTION { return Storage.getValue(); }
|
|
|
|
|
|
explicit operator bool() const { return hasValue(); }
|
|
explicit operator bool() const { return hasValue(); }
|
|
bool hasValue() const { return Storage.hasValue(); }
|
|
bool hasValue() const { return Storage.hasValue(); }
|
|
const T *operator->() const { return getPointer(); }
|
|
const T *operator->() const { return getPointer(); }
|
|
T *operator->() { return getPointer(); }
|
|
T *operator->() { return getPointer(); }
|
|
- const T &operator*() const & { return getValue(); }
|
|
|
|
- T &operator*() & { return getValue(); }
|
|
|
|
|
|
+ const T &operator*() const LLVM_LVALUE_FUNCTION { return getValue(); }
|
|
|
|
+ T &operator*() LLVM_LVALUE_FUNCTION { return getValue(); }
|
|
|
|
|
|
template <typename U>
|
|
template <typename U>
|
|
- constexpr T getValueOr(U &&value) const & {
|
|
|
|
|
|
+ constexpr T getValueOr(U &&value) const LLVM_LVALUE_FUNCTION {
|
|
return hasValue() ? getValue() : std::forward<U>(value);
|
|
return hasValue() ? getValue() : std::forward<U>(value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
|
|
T &&getValue() && { return std::move(Storage.getValue()); }
|
|
T &&getValue() && { return std::move(Storage.getValue()); }
|
|
T &&operator*() && { return std::move(Storage.getValue()); }
|
|
T &&operator*() && { return std::move(Storage.getValue()); }
|
|
|
|
|
|
@@ -271,6 +275,7 @@ public:
|
|
T getValueOr(U &&value) && {
|
|
T getValueOr(U &&value) && {
|
|
return hasValue() ? std::move(getValue()) : std::forward<U>(value);
|
|
return hasValue() ? std::move(getValue()) : std::forward<U>(value);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
};
|
|
};
|
|
|
|
|
|
template <typename T, typename U>
|
|
template <typename T, typename U>
|