From 5d16475b3176250b1fad0f59a03863456db00e66 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 8 Jan 2014 21:17:09 +0000 Subject: [PATCH] Add get and getError methods to ErrorOr. ErrorOr is modeled after boost::optional which has a get method. llvm-svn: 198792 --- llvm/include/llvm/Support/ErrorOr.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/llvm/include/llvm/Support/ErrorOr.h b/llvm/include/llvm/Support/ErrorOr.h index 26af1e8c8004..21ab4e721dcf 100644 --- a/llvm/include/llvm/Support/ErrorOr.h +++ b/llvm/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 >(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()); }