summaryrefslogtreecommitdiff
path: root/include/Support/ilist
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-07-24 20:44:01 +0000
committerChris Lattner <sabre@nondot.org>2002-07-24 20:44:01 +0000
commita1cb4737b04a92f57b1b9dcd8a24c68db5035401 (patch)
tree1620ec9cb03e4652ac02eb5ccbfda5307d4d3f12 /include/Support/ilist
parent5a6d63ae29512d654c8c697f42f32f97b9dc010b (diff)
downloadllvm-a1cb4737b04a92f57b1b9dcd8a24c68db5035401.tar.gz
llvm-a1cb4737b04a92f57b1b9dcd8a24c68db5035401.tar.bz2
llvm-a1cb4737b04a92f57b1b9dcd8a24c68db5035401.tar.xz
Changes to make it GCC 3.1 compatible
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3052 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/Support/ilist')
-rw-r--r--include/Support/ilist23
1 files changed, 20 insertions, 3 deletions
diff --git a/include/Support/ilist b/include/Support/ilist
index 7e666c6d97..09c951c257 100644
--- a/include/Support/ilist
+++ b/include/Support/ilist
@@ -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 {