[ADT] Remove Optional::{has_value,value}, etc (NFC)
This patch removes methods that I deprecated on August, 2022 in commitsb5f8d42efeandeeac9e9232. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
This commit is contained in:
1 parent
34bcadc38c
commit
4b6b248731
2 files changed
-40
No files matched your search
@@ -277,21 +277,10 @@ public:
|
||||
constexpr const T *getPointer() const { return &Storage.value(); }
|
||||
T *getPointer() { return &Storage.value(); }
|
||||
constexpr const T &value() const & { return Storage.value(); }
|
||||
LLVM_DEPRECATED("Use value instead.", "value")
|
||||
constexpr const T &getValue() const & {
|
||||
return Storage.value();
|
||||
}
|
||||
T &value() & { return Storage.value(); }
|
||||
LLVM_DEPRECATED("Use value instead.", "value") T &getValue() & {
|
||||
return Storage.value();
|
||||
}
|
||||
|
||||
constexpr explicit operator bool() const { return has_value(); }
|
||||
constexpr bool has_value() const { return Storage.has_value(); }
|
||||
LLVM_DEPRECATED("Use has_value instead.", "has_value")
|
||||
constexpr bool hasValue() const {
|
||||
return Storage.has_value();
|
||||
}
|
||||
constexpr const T *operator->() const { return getPointer(); }
|
||||
T *operator->() { return getPointer(); }
|
||||
constexpr const T &operator*() const & { return value(); }
|
||||
@@ -300,11 +289,6 @@ public:
|
||||
template <typename U> constexpr T value_or(U &&alt) const & {
|
||||
return has_value() ? value() : std::forward<U>(alt);
|
||||
}
|
||||
template <typename U>
|
||||
LLVM_DEPRECATED("Use value_or instead.", "value_or")
|
||||
constexpr T getValueOr(U &&alt) const & {
|
||||
return has_value() ? value() : std::forward<U>(alt);
|
||||
}
|
||||
|
||||
/// Apply a function to the value if present; otherwise return None.
|
||||
template <class Function>
|
||||
@@ -313,28 +297,13 @@ public:
|
||||
return F(value());
|
||||
return None;
|
||||
}
|
||||
template <class Function>
|
||||
LLVM_DEPRECATED("Use transform instead.", "transform")
|
||||
auto map(const Function &F) const & -> Optional<decltype(F(value()))> {
|
||||
if (*this)
|
||||
return F(value());
|
||||
return None;
|
||||
}
|
||||
|
||||
T &&value() && { return std::move(Storage.value()); }
|
||||
LLVM_DEPRECATED("Use value instead.", "value") T &&getValue() && {
|
||||
return std::move(Storage.value());
|
||||
}
|
||||
T &&operator*() && { return std::move(Storage.value()); }
|
||||
|
||||
template <typename U> T value_or(U &&alt) && {
|
||||
return has_value() ? std::move(value()) : std::forward<U>(alt);
|
||||
}
|
||||
template <typename U>
|
||||
LLVM_DEPRECATED("Use value_or instead.", "value_or")
|
||||
T getValueOr(U &&alt) && {
|
||||
return has_value() ? std::move(value()) : std::forward<U>(alt);
|
||||
}
|
||||
|
||||
/// Apply a function to the value if present; otherwise return None.
|
||||
template <class Function>
|
||||
@@ -344,14 +313,6 @@ public:
|
||||
return F(std::move(*this).value());
|
||||
return None;
|
||||
}
|
||||
template <class Function>
|
||||
LLVM_DEPRECATED("Use transform instead.", "transform")
|
||||
auto map(const Function &F)
|
||||
&& -> Optional<decltype(F(std::move(*this).value()))> {
|
||||
if (*this)
|
||||
return F(std::move(*this).value());
|
||||
return None;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
private:
|
||||
/// Hide the bool conversion as it easily creates confusion.
|
||||
using Optional<T>::operator bool;
|
||||
using Optional<T>::hasValue;
|
||||
using Optional<T>::has_value;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user