[PATCH] D49298: Use std::reference_wrapper instead of llvm::ReferenceStorage

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 13 08:04:44 PDT 2018


serge-sans-paille created this revision.
serge-sans-paille added a reviewer: Bigcheese.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D49298

Files:
  include/llvm/Support/Error.h
  include/llvm/Support/ErrorOr.h


Index: include/llvm/Support/ErrorOr.h
===================================================================
--- include/llvm/Support/ErrorOr.h
+++ include/llvm/Support/ErrorOr.h
@@ -24,18 +24,6 @@
 
 namespace llvm {
 
-/// Stores a reference that can be changed.
-template <typename T>
-class ReferenceStorage {
-  T *Storage;
-
-public:
-  ReferenceStorage(T &Ref) : Storage(&Ref) {}
-
-  operator T &() const { return *Storage; }
-  T &get() const { return *Storage; }
-};
-
 /// Represents either an error or a value T.
 ///
 /// ErrorOr<T> is a pointer-like class that represents the result of an
@@ -71,7 +59,7 @@
 
   static const bool isRef = std::is_reference<T>::value;
 
-  using wrap = ReferenceStorage<typename std::remove_reference<T>::type>;
+  using wrap = std::reference_wrapper<typename std::remove_reference<T>::type>;
 
 public:
   using storage_type = typename std::conditional<isRef, wrap, T>::type;
Index: include/llvm/Support/Error.h
===================================================================
--- include/llvm/Support/Error.h
+++ include/llvm/Support/Error.h
@@ -429,7 +429,7 @@
 
   static const bool isRef = std::is_reference<T>::value;
 
-  using wrap = ReferenceStorage<typename std::remove_reference<T>::type>;
+  using wrap = std::reference_wrapper<typename std::remove_reference<T>::type>;
 
   using error_type = std::unique_ptr<ErrorInfoBase>;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49298.155389.patch
Type: text/x-patch
Size: 1386 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180713/9f02793a/attachment.bin>


More information about the llvm-commits mailing list