From a33e1fafac7fedb1b080ef07ddf9ad6ddff3a830 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Tue, 5 Feb 2013 08:22:27 +0000 Subject: [Support][ErrorOr] Add support for convertable types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174357 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ErrorOr.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/llvm/Support') diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 452d85c..653b9e5 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -162,6 +162,7 @@ public: /// T cannot be a rvalue reference. template class ErrorOr { + template friend class ErrorOr; static const bool isRef = is_reference::value; typedef ReferenceStorage::type> wrap; @@ -198,7 +199,8 @@ public: new (get()) storage_type(moveIfMoveConstructible(Val)); } - ErrorOr(const ErrorOr &Other) : IsValid(false) { + template + ErrorOr(ErrorOr &Other) : IsValid(false) { // Construct an invalid ErrorOr if other is invalid. if (!Other.IsValid) return; @@ -227,7 +229,8 @@ public: } #if LLVM_HAS_RVALUE_REFERENCES - ErrorOr(ErrorOr &&Other) : IsValid(false) { + template + ErrorOr(ErrorOr &&Other) : IsValid(false) { // Construct an invalid ErrorOr if other is invalid. if (!Other.IsValid) return; @@ -311,7 +314,6 @@ private: return &Val->get(); } -protected: storage_type *get() { assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); assert(!HasError && "Cannot get value when an error exists!"); -- cgit v1.1