Changes to make it GCC 3.1 compatible
authorChris Lattner <sabre@nondot.org>
Wed, 24 Jul 2002 20:44:01 +0000 (20:44 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 24 Jul 2002 20:44:01 +0000 (20:44 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3052 91177308-0d34-0410-b5e6-96231b3b80d8

include/Support/ilist
include/llvm/ADT/ilist

index 7e666c6d97f167c1550f28386acd8ccb25baf423..09c951c2572d57e9818cd5d4f47595815a898347 100644 (file)
@@ -12,7 +12,7 @@
 // The ilist class itself, should be a plug in replacement for list, assuming
 // that the nodes contain next/prev pointers.  This list replacement does not
 // provides a constant time size() method, so be careful to use empty() when you
-// really want to know if I'm empty.
+// really want to know if it's empty.
 //
 // The ilist class is implemented by allocating a 'tail' node when the list is
 // created (using ilist_traits<>::createEndMarker()).  This tail node is
@@ -33,6 +33,7 @@
 
 #include <assert.h>
 #include <iterator>
+#include <algorithm>
 
 template<typename NodeTy, typename Traits> class iplist;
 template<typename NodeTy> class ilist_iterator;
@@ -69,8 +70,18 @@ struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
 // ilist_iterator<Node> - Iterator for intrusive list.
 //
 template<typename NodeTy>
-class ilist_iterator : public std::bidirectional_iterator<NodeTy, ptrdiff_t> {
+class ilist_iterator
+#if __GNUC__ == 3
+  : public std::iterator<std::bidirectional_iterator_tag, NodeTy> {
+  typedef std::iterator<std::bidirectional_iterator_tag, NodeTy> super;
+#else
+  : public std::bidirectional_iterator<NodeTy, ptrdiff_t> {
+  typedef std::bidirectional_iterator<NodeTy, ptrdiff_t> super;
+#endif
   typedef ilist_traits<NodeTy> Traits;
+
+  typedef typename super::pointer pointer;
+  typedef typename super::reference reference;
   pointer NodePtr;
 public:
   typedef size_t size_type;
@@ -301,8 +312,12 @@ public:
   //
 
   size_type size() const {
+#if __GNUC__ == 3
+    size_type Result = std::distance(begin(), end());
+#else
     size_type Result = 0;
     std::distance(begin(), end(), Result);
+#endif
     return Result;
   }
 
@@ -404,6 +419,9 @@ public:
 
 template<typename NodeTy>
 struct ilist : public iplist<NodeTy> {
+  typedef typename iplist<NodeTy>::size_type size_type;
+  typedef typename iplist<NodeTy>::iterator iterator;
+
   ilist() {}
   ilist(const ilist &right) {
     insert(begin(), right.begin(), right.end());
@@ -478,7 +496,6 @@ struct ilist : public iplist<NodeTy> {
       insert(end(), newsize - len, val);
   }
   void resize(size_type newsize) { resize(newsize, NodeTy()); }
-
 };
 
 namespace std {
index 7e666c6d97f167c1550f28386acd8ccb25baf423..09c951c2572d57e9818cd5d4f47595815a898347 100644 (file)
@@ -12,7 +12,7 @@
 // The ilist class itself, should be a plug in replacement for list, assuming
 // that the nodes contain next/prev pointers.  This list replacement does not
 // provides a constant time size() method, so be careful to use empty() when you
-// really want to know if I'm empty.
+// really want to know if it's empty.
 //
 // The ilist class is implemented by allocating a 'tail' node when the list is
 // created (using ilist_traits<>::createEndMarker()).  This tail node is
@@ -33,6 +33,7 @@
 
 #include <assert.h>
 #include <iterator>
+#include <algorithm>
 
 template<typename NodeTy, typename Traits> class iplist;
 template<typename NodeTy> class ilist_iterator;
@@ -69,8 +70,18 @@ struct ilist_traits<const Ty> : public ilist_traits<Ty> {};
 // ilist_iterator<Node> - Iterator for intrusive list.
 //
 template<typename NodeTy>
-class ilist_iterator : public std::bidirectional_iterator<NodeTy, ptrdiff_t> {
+class ilist_iterator
+#if __GNUC__ == 3
+  : public std::iterator<std::bidirectional_iterator_tag, NodeTy> {
+  typedef std::iterator<std::bidirectional_iterator_tag, NodeTy> super;
+#else
+  : public std::bidirectional_iterator<NodeTy, ptrdiff_t> {
+  typedef std::bidirectional_iterator<NodeTy, ptrdiff_t> super;
+#endif
   typedef ilist_traits<NodeTy> Traits;
+
+  typedef typename super::pointer pointer;
+  typedef typename super::reference reference;
   pointer NodePtr;
 public:
   typedef size_t size_type;
@@ -301,8 +312,12 @@ public:
   //
 
   size_type size() const {
+#if __GNUC__ == 3
+    size_type Result = std::distance(begin(), end());
+#else
     size_type Result = 0;
     std::distance(begin(), end(), Result);
+#endif
     return Result;
   }
 
@@ -404,6 +419,9 @@ public:
 
 template<typename NodeTy>
 struct ilist : public iplist<NodeTy> {
+  typedef typename iplist<NodeTy>::size_type size_type;
+  typedef typename iplist<NodeTy>::iterator iterator;
+
   ilist() {}
   ilist(const ilist &right) {
     insert(begin(), right.begin(), right.end());
@@ -478,7 +496,6 @@ struct ilist : public iplist<NodeTy> {
       insert(end(), newsize - len, val);
   }
   void resize(size_type newsize) { resize(newsize, NodeTy()); }
-
 };
 
 namespace std {