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

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 19 02:29:50 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL337444: Use std::reference_wrapper instead of llvm::ReferenceStorage (authored by serge_sans_paille, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49298?vs=155389&id=156221#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49298

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


Index: llvm/trunk/include/llvm/Support/ErrorOr.h
===================================================================
--- llvm/trunk/include/llvm/Support/ErrorOr.h
+++ llvm/trunk/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: llvm/trunk/include/llvm/Support/Error.h
===================================================================
--- llvm/trunk/include/llvm/Support/Error.h
+++ llvm/trunk/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.156221.patch
Type: text/x-patch
Size: 1452 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180719/4a6698a5/attachment.bin>


More information about the llvm-commits mailing list