diff options
-rw-r--r-- | include/Support/ilist | 23 | ||||
-rw-r--r-- | include/llvm/ADT/ilist | 23 |
2 files changed, 40 insertions, 6 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 { diff --git a/include/llvm/ADT/ilist b/include/llvm/ADT/ilist index 7e666c6d97..09c951c257 100644 --- a/include/llvm/ADT/ilist +++ b/include/llvm/ADT/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 { |