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
This commit is contained in:
Chris Lattner 2002-07-24 20:44:01 +00:00
parent 5a6d63ae29
commit a1cb4737b0
2 changed files with 40 additions and 6 deletions

View 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 {

View 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 {