[llvm] r198792 - Add get and getError methods to ErrorOr.

Rafael Espindola rafael.espindola at gmail.com
Wed Jan 8 13:17:09 PST 2014


Author: rafael
Date: Wed Jan  8 15:17:09 2014
New Revision: 198792

URL: http://llvm.org/viewvc/llvm-project?rev=198792&view=rev
Log:
Add get and getError methods to ErrorOr.

ErrorOr is modeled after boost::optional which has a get method.

Modified:
    llvm/trunk/include/llvm/Support/ErrorOr.h

Modified: llvm/trunk/include/llvm/Support/ErrorOr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorOr.h?rev=198792&r1=198791&r2=198792&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorOr.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorOr.h Wed Jan  8 15:17:09 2014
@@ -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());
   }





More information about the llvm-commits mailing list