[llvm] r337444 - Use std::reference_wrapper instead of llvm::ReferenceStorage

Serge Guelton via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 19 02:24:34 PDT 2018


Author: serge_sans_paille
Date: Thu Jul 19 02:24:34 2018
New Revision: 337444

URL: http://llvm.org/viewvc/llvm-project?rev=337444&view=rev
Log:
Use std::reference_wrapper instead of llvm::ReferenceStorage

Reviewed By: Bigcheese
Differential Revision: https://reviews.llvm.org/D49298

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

Modified: llvm/trunk/include/llvm/Support/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Error.h?rev=337444&r1=337443&r2=337444&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Error.h (original)
+++ llvm/trunk/include/llvm/Support/Error.h Thu Jul 19 02:24:34 2018
@@ -429,7 +429,7 @@ template <class T> class LLVM_NODISCARD
 
   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>;
 

Modified: llvm/trunk/include/llvm/Support/ErrorOr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorOr.h?rev=337444&r1=337443&r2=337444&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorOr.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorOr.h Thu Jul 19 02:24:34 2018
@@ -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 @@ class ErrorOr {
 
   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;




More information about the llvm-commits mailing list