diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-08 21:17:09 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-08 21:17:09 +0000 |
commit | d13e173eb627276ab546b05195c05fcbdf6a8baa (patch) | |
tree | f4c0086577f82dd9f0be60a9e5bee2d2c90a50e0 | |
parent | cb1f0ddce42c2da8428e331532518d753e62fd1b (diff) | |
download | llvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.gz llvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.bz2 llvm-d13e173eb627276ab546b05195c05fcbdf6a8baa.tar.xz |
Add get and getError methods to ErrorOr.
ErrorOr is modeled after boost::optional which has a get method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198792 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Support/ErrorOr.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 26af1e8c80..21ab4e721d 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -178,10 +178,17 @@ public: return HasError ? 0 : unspecified_bool_true; } + T &get() { return *getStorage(); } + const T &get() const { return const_cast<ErrorOr<T> >(this)->get(); } + operator llvm::error_code() const { return HasError ? *getErrorStorage() : llvm::error_code::success(); } + error_code getError() const { + return HasError ? *getErrorStorage() : error_code::success(); + } + pointer operator ->() { return toPointer(getStorage()); } |