[llvm] r279086 - Revert "ADT: Remove references in has_rbegin for reverse()"

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 09:27:41 PDT 2016


Author: dexonsmith
Date: Thu Aug 18 11:27:41 2016
New Revision: 279086

URL: http://llvm.org/viewvc/llvm-project?rev=279086&view=rev
Log:
Revert "ADT: Remove references in has_rbegin for reverse()"

This reverts commit r279084, since it failed on a bot:
  http://bb.pgr.jp/builders/cmake-llvm-x86_64-linux/builds/41733

Modified:
    llvm/trunk/include/llvm/ADT/STLExtras.h
    llvm/trunk/unittests/ADT/RangeAdapterTest.cpp

Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=279086&r1=279085&r2=279086&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Thu Aug 18 11:27:41 2016
@@ -208,8 +208,9 @@ inline mapped_iterator<ItTy, FuncTy> map
   return mapped_iterator<ItTy, FuncTy>(I, F);
 }
 
-/// Helper to determine if type T has a member called rbegin().
-template <typename Ty> class has_rbegin_impl {
+/// \brief Metafunction to determine if type T has a member called rbegin().
+template <typename Ty>
+class has_rbegin {
   typedef char yes[1];
   typedef char no[2];
 
@@ -223,11 +224,6 @@ public:
   static const bool value = sizeof(test<Ty>(nullptr)) == sizeof(yes);
 };
 
-/// Metafunction to determine if T& or T has a member called rbegin().
-template <typename Ty>
-struct has_rbegin : has_rbegin_impl<typename std::remove_reference<Ty>::type> {
-};
-
 // Returns an iterator_range over the given container which iterates in reverse.
 // Note that the container must have rbegin()/rend() methods for this to work.
 template <typename ContainerTy>

Modified: llvm/trunk/unittests/ADT/RangeAdapterTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/RangeAdapterTest.cpp?rev=279086&r1=279085&r2=279086&view=diff
==============================================================================
--- llvm/trunk/unittests/ADT/RangeAdapterTest.cpp (original)
+++ llvm/trunk/unittests/ADT/RangeAdapterTest.cpp Thu Aug 18 11:27:41 2016
@@ -75,50 +75,6 @@ public:
   const_reverse_iterator rend() const { return Vec.rend(); }
 };
 
-/// Check that types with custom iterators work.
-class CustomIteratorVector {
-  mutable std::vector<int> V;
-
-public:
-  CustomIteratorVector(std::initializer_list<int> list) : V(list) {}
-
-  typedef std::vector<int>::iterator iterator;
-  class reverse_iterator {
-    std::vector<int>::iterator I;
-
-  public:
-    reverse_iterator() = default;
-    reverse_iterator(const reverse_iterator &) = default;
-    reverse_iterator &operator=(const reverse_iterator &) = default;
-
-    explicit reverse_iterator(std::vector<int>::iterator I) : I(I) {}
-
-    reverse_iterator &operator++() {
-      --I;
-      return *this;
-    }
-    reverse_iterator &operator--() {
-      ++I;
-      return *this;
-    }
-    int &operator*() const { return *std::prev(I); }
-    int *operator->() const { return &*std::prev(I); }
-    friend bool operator==(const reverse_iterator &L,
-                           const reverse_iterator &R) {
-      return L.I == R.I;
-    }
-    friend bool operator!=(const reverse_iterator &L,
-                           const reverse_iterator &R) {
-      return !(L == R);
-    }
-  };
-
-  iterator begin() const { return V.begin(); }
-  iterator end()  const { return V.end(); }
-  reverse_iterator rbegin() const { return reverse_iterator(V.end()); }
-  reverse_iterator rend() const { return reverse_iterator(V.begin()); }
-};
-
 template <typename R> void TestRev(const R &r) {
   int counter = 3;
   for (int i : r)
@@ -142,10 +98,9 @@ TYPED_TEST(RangeAdapterLValueTest, Trivi
 
 template <typename T> struct RangeAdapterRValueTest : testing::Test {};
 
-typedef ::testing::Types<std::vector<int>, std::list<int>, CustomIteratorVector,
-                         ReverseOnlyVector, BidirectionalVector,
-                         BidirectionalVectorConsts>
-    RangeAdapterRValueTestTypes;
+typedef ::testing::Types<std::vector<int>, std::list<int>, ReverseOnlyVector,
+                         BidirectionalVector,
+                         BidirectionalVectorConsts> RangeAdapterRValueTestTypes;
 TYPED_TEST_CASE(RangeAdapterRValueTest, RangeAdapterRValueTestTypes);
 
 TYPED_TEST(RangeAdapterRValueTest, TrivialOperation) {
@@ -153,20 +108,7 @@ TYPED_TEST(RangeAdapterRValueTest, Trivi
 }
 
 TYPED_TEST(RangeAdapterRValueTest, HasRbegin) {
-  static_assert(has_rbegin<TypeParam>::value, "rbegin() should be defined");
-}
-
-TYPED_TEST(RangeAdapterRValueTest, RangeType) {
-  static_assert(
-      std::is_same<
-          decltype(reverse(*static_cast<TypeParam *>(nullptr)).begin()),
-          decltype(static_cast<TypeParam *>(nullptr)->rbegin())>::value,
-      "reverse().begin() should have the same type as rbegin()");
-  static_assert(
-      std::is_same<
-          decltype(reverse(*static_cast<const TypeParam *>(nullptr)).begin()),
-          decltype(static_cast<const TypeParam *>(nullptr)->rbegin())>::value,
-      "reverse().begin() should have the same type as rbegin() [const]");
+  EXPECT_TRUE(has_rbegin<TypeParam>::value);
 }
 
 } // anonymous namespace




More information about the llvm-commits mailing list