Commit ff893307 by Jason Merrill Committed by Jason Merrill

algo.h, [...]: Update To September 8 SGI release.

	* algo.h, algobase.h, alloc.h, bvector.h, deque.h, hashtable.h,
	iterator.h, list.h, rope.h, ropeimpl.h, slist.h, stl_config.h,
	tree.h, vector.h: Update To September 8 SGI release.

From-SVN: r15211
parent c6b50f10
Tue Sep 9 19:47:28 1997 Jason Merrill <jason@yorick.cygnus.com>
* algo.h, algobase.h, alloc.h, bvector.h, deque.h, hashtable.h,
iterator.h, list.h, rope.h, ropeimpl.h, slist.h, stl_config.h,
tree.h, vector.h: Update To September 8 SGI release.
Tue Sep 9 17:38:47 1997 Mark Mitchell <mmitchell@usa.net>
* stl_config.h (__STL_MEMBER_TEMPLATES): Enable.
......
......@@ -86,19 +86,6 @@ inline void __distance(InputIterator first, InputIterator last, Distance& n,
while (first != last) { ++first; ++n; }
}
template <class ForwardIterator, class Distance>
inline void __distance(ForwardIterator first, ForwardIterator last,
Distance& n,
forward_iterator_tag) {
while (first != last) { ++first; ++n; }
}
template <class BidirectionalIterator, class Distance>
inline void __distance(BidirectionalIterator first, BidirectionalIterator last,
Distance& n, bidirectional_iterator_tag) {
while (first != last) { ++first; ++n; }
}
template <class RandomAccessIterator, class Distance>
inline void __distance(RandomAccessIterator first, RandomAccessIterator last,
Distance& n, random_access_iterator_tag) {
......@@ -122,19 +109,6 @@ __distance(InputIterator first, InputIterator last, input_iterator_tag) {
return n;
}
template <class ForwardIterator>
inline iterator_traits<ForwardIterator>::difference_type
__distance(ForwardIterator first, ForwardIterator last, forward_iterator_tag) {
return __distance(first, last, input_iterator_tag());
}
template <class BidirectionalIterator>
inline iterator_traits<BidirectionalIterator>::difference_type
__distance(BidirectionalIterator first, BidirectionalIterator last,
bidirectional_iterator_tag) {
return __distance(first, last, input_iterator_tag());
}
template <class RandomAccessIterator>
inline iterator_traits<RandomAccessIterator>::difference_type
__distance(RandomAccessIterator first, RandomAccessIterator last,
......@@ -156,11 +130,6 @@ inline void __advance(InputIterator& i, Distance n, input_iterator_tag) {
while (n--) ++i;
}
template <class ForwardIterator, class Distance>
inline void __advance(ForwardIterator& i, Distance n, forward_iterator_tag) {
while (n--) ++i;
}
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma set woff 1183
#endif
......@@ -198,20 +167,6 @@ inline OutputIterator __copy(InputIterator first, InputIterator last,
return result;
}
template <class InputIterator, class OutputIterator>
inline OutputIterator __copy(InputIterator first, InputIterator last,
OutputIterator result, forward_iterator_tag)
{
return __copy(first, last, result, input_iterator_tag());
}
template <class InputIterator, class OutputIterator>
inline OutputIterator __copy(InputIterator first, InputIterator last,
OutputIterator result, bidirectional_iterator_tag)
{
return __copy(first, last, result, input_iterator_tag());
}
template <class RandomAccessIterator, class OutputIterator, class Distance>
inline OutputIterator
__copy_d(RandomAccessIterator first, RandomAccessIterator last,
......@@ -365,20 +320,6 @@ OutputIterator __copy_n(InputIterator first, Size count,
return result;
}
template <class ForwardIterator, class Size, class OutputIterator>
inline OutputIterator __copy_n(ForwardIterator first, Size count,
OutputIterator result,
forward_iterator_tag) {
return __copy_n(first, count, result, input_iterator_tag());
}
template <class BidirectionalIterator, class Size, class OutputIterator>
inline OutputIterator __copy_n(BidirectionalIterator first, Size count,
OutputIterator result,
bidirectional_iterator_tag) {
return __copy_n(first, count, result, input_iterator_tag());
}
template <class RandomAccessIterator, class Size, class OutputIterator>
inline OutputIterator __copy_n(RandomAccessIterator first, Size count,
OutputIterator result,
......@@ -657,22 +598,6 @@ ForwardIterator __uninitialized_copy_n(InputIterator first, Size count,
# endif /* __STL_USE_EXCEPTIONS */
}
template <class ForwardIterator1, class Size, class ForwardIterator>
inline ForwardIterator
__uninitialized_copy_n(ForwardIterator1 first, Size count,
ForwardIterator result,
forward_iterator_tag) {
return __uninitialized_copy_n(first, count, result, input_iterator_tag());
}
template <class BidirectionalIterator, class Size, class ForwardIterator>
inline ForwardIterator
__uninitialized_copy_n(BidirectionalIterator first, Size count,
ForwardIterator result,
bidirectional_iterator_tag) {
return __uninitialized_copy_n(first, count, result, input_iterator_tag());
}
template <class RandomAccessIterator, class Size, class ForwardIterator>
inline ForwardIterator
__uninitialized_copy_n(RandomAccessIterator first, Size count,
......
......@@ -49,7 +49,6 @@
#endif
#ifdef __STL_WIN32THREADS
# include <windows.h>
// This must precede stl_config.h
#endif
#include <stddef.h>
......@@ -91,7 +90,11 @@
// This should work without threads, with sproc threads, or with
// pthreads. It is suboptimal in all cases.
// It is unlikely to even compile on nonSGI machines.
# include <malloc.h>
extern int __us_rsthread_malloc;
// The above is copied from malloc.h. Including <malloc.h>
// would be cleaner but fails with certain levels of standard
// conformance.
# define __NODE_ALLOCATOR_LOCK if (threads && __us_rsthread_malloc) \
{ __lock(&__node_allocator_lock); }
# define __NODE_ALLOCATOR_UNLOCK if (threads && __us_rsthread_malloc) \
......@@ -383,15 +386,17 @@ public:
obj * __VOLATILE * my_free_list;
obj * __RESTRICT result;
if (n > __MAX_BYTES) {
if (n > (size_t) __MAX_BYTES) {
return(malloc_alloc::allocate(n));
}
my_free_list = free_list + FREELIST_INDEX(n);
// Acquire the lock here with a constructor call.
// This ensures that it is released in exit or during stack
// unwinding.
# ifndef _NOTHREADS
/*REFERENCED*/
lock lock_instance;
# endif
result = *my_free_list;
if (result == 0) {
void *r = refill(ROUND_UP(n));
......@@ -407,14 +412,16 @@ public:
obj *q = (obj *)p;
obj * __VOLATILE * my_free_list;
if (n > __MAX_BYTES) {
if (n > (size_t) __MAX_BYTES) {
malloc_alloc::deallocate(p, n);
return;
}
my_free_list = free_list + FREELIST_INDEX(n);
// acquire lock
# ifndef _NOTHREADS
/*REFERENCED*/
lock lock_instance;
# endif /* _NOTHREADS */
q -> free_list_link = *my_free_list;
*my_free_list = q;
// lock is released here
......@@ -480,6 +487,7 @@ __default_alloc_template<threads, inst>::chunk_alloc(size_t size, int& nobjs)
// right free list.
}
}
end_free = 0; // In case of exception.
start_free = (char *)malloc_alloc::allocate(bytes_to_get);
// This should either throw an
// exception or remedy the situation. Thus we assume it
......@@ -533,7 +541,7 @@ __default_alloc_template<threads, inst>::reallocate(void *p,
void * result;
size_t copy_sz;
if (old_sz > __MAX_BYTES && new_sz > __MAX_BYTES) {
if (old_sz > (size_t) __MAX_BYTES && new_sz > (size_t) __MAX_BYTES) {
return(realloc(p, new_sz));
}
if (ROUND_UP(old_sz) == ROUND_UP(new_sz)) return(p);
......@@ -671,4 +679,6 @@ __default_alloc_template<threads, inst> ::free_list[
#pragma reset woff 1174
#endif
#endif /* __NODE_ALLOC_H */
#undef __PRIVATE
#endif /* __ALLOC_H */
......@@ -82,7 +82,8 @@ public:
friend class bit_vector;
friend class const_iterator;
public:
typedef bit_reference reference;
typedef bit_reference reference;
typedef bit_reference* pointer;
protected:
unsigned int* p;
unsigned int offset;
......@@ -163,6 +164,7 @@ public:
friend class bit_vector;
public:
typedef bit_const_reference reference;
typedef const bool* pointer;
protected:
unsigned int* p;
unsigned int offset;
......@@ -243,10 +245,15 @@ public:
}
};
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
typedef reverse_iterator<const_iterator, value_type, const_reference,
difference_type> const_reverse_iterator;
typedef reverse_iterator<iterator, value_type, reference, difference_type>
reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
protected:
typedef simple_alloc<unsigned int, alloc> data_allocator;
......@@ -303,20 +310,6 @@ protected:
copy(first, last, start);
}
template <class BidirectionalIterator>
void initialize_range(BidirectionalIterator first,
BidirectionalIterator last,
bidirectional_iterator_tag) {
initialize_range(first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void initialize_range(RandomAccessIterator first,
RandomAccessIterator last,
random_access_iterator_tag) {
initialize_range(first, last, forward_iterator_tag());
}
template <class InputIterator>
void insert_range(iterator pos,
InputIterator first, InputIterator last,
......@@ -352,20 +345,6 @@ protected:
}
}
template <class BidirectionalIterator>
void insert_range(iterator pos,
BidirectionalIterator first, BidirectionalIterator last,
bidirectional_iterator_tag) {
insert_range(pos, first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void insert_range(iterator pos,
RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
insert_range(pos, first, last, forward_iterator_tag());
}
#endif /* __STL_MEMBER_TEMPLATES */
typedef bit_vector self;
......
......@@ -87,42 +87,44 @@ inline size_t __deque_buf_size(size_t n, size_t sz)
}
#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG
template <class T, class Ref, size_t BufSiz>
template <class T, class Ref, class Ptr, size_t BufSiz>
struct __deque_iterator {
typedef __deque_iterator<T, T&, BufSiz> iterator;
typedef __deque_iterator<T, const T&, BufSiz> const_iterator;
typedef __deque_iterator<T, T&, T*, BufSiz> iterator;
typedef __deque_iterator<T, const T&, const T*, BufSiz> const_iterator;
static size_t buffer_size() {return __deque_buf_size(BufSiz, sizeof(T)); }
#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */
template <class T, class Ref>
template <class T, class Ref, class Ptr>
struct __deque_iterator {
typedef __deque_iterator<T, T&> iterator;
typedef __deque_iterator<T, const T&> const_iterator;
typedef __deque_iterator<T, T&, T*> iterator;
typedef __deque_iterator<T, const T&, const T*> const_iterator;
static size_t buffer_size() {return __deque_buf_size(0, sizeof(T)); }
#endif
typedef random_access_iterator_tag iterator_category;
typedef T value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef Ptr pointer;
typedef Ref reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef pointer* map_pointer;
typedef T** map_pointer;
typedef __deque_iterator self;
pointer cur;
pointer first;
pointer last;
T* cur;
T* first;
T* last;
map_pointer node;
__deque_iterator(pointer x, map_pointer y)
__deque_iterator(T* x, map_pointer y)
: cur(x), first(*y), last(*y + buffer_size()), node(y) {}
__deque_iterator() : cur(0), first(0), last(0), node(0) {}
__deque_iterator(const iterator& x)
: cur(x.cur), first(x.first), last(x.last), node(x.node) {}
Ref operator*() const { return *cur; }
reference operator*() const { return *cur; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
difference_type operator-(const self& x) const {
return buffer_size() * (node - x.node - 1) +
......@@ -183,7 +185,7 @@ struct __deque_iterator {
return tmp -= n;
}
Ref operator[](difference_type n) const { return *(*this + n); }
reference operator[](difference_type n) const { return *(*this + n); }
bool operator==(const self& x) const { return cur == x.cur; }
bool operator!=(const self& x) const { return !(*this == x); }
......@@ -198,40 +200,45 @@ struct __deque_iterator {
}
};
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG
template <class T, class Ref, size_t BufSiz>
template <class T, class Ref, class Ptr, size_t BufSiz>
inline random_access_iterator_tag
iterator_category(const __deque_iterator<T, Ref, BufSiz>&) {
iterator_category(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {
return random_access_iterator_tag();
}
template <class T, class Ref, size_t BufSiz>
inline T* value_type(const __deque_iterator<T, Ref, BufSiz>&) { return 0; }
template <class T, class Ref, class Ptr, size_t BufSiz>
inline T* value_type(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {
return 0;
}
template <class T, class Ref, size_t BufSiz>
inline ptrdiff_t* distance_type(const __deque_iterator<T, Ref, BufSiz>&) {
template <class T, class Ref, class Ptr, size_t BufSiz>
inline ptrdiff_t* distance_type(const __deque_iterator<T, Ref, Ptr, BufSiz>&) {
return 0;
}
#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */
template <class T, class Ref>
template <class T, class Ref, class Ptr>
inline random_access_iterator_tag
iterator_category(const __deque_iterator<T, Ref>&) {
iterator_category(const __deque_iterator<T, Ref, Ptr>&) {
return random_access_iterator_tag();
}
template <class T, class Ref>
inline T* value_type(const __deque_iterator<T, Ref>&) { return 0; }
template <class T, class Ref, class Ptr>
inline T* value_type(const __deque_iterator<T, Ref, Ptr>&) { return 0; }
template <class T, class Ref>
inline ptrdiff_t* distance_type(const __deque_iterator<T, Ref>&) {
template <class T, class Ref, class Ptr>
inline ptrdiff_t* distance_type(const __deque_iterator<T, Ref, Ptr>&) {
return 0;
}
#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
// See __deque_buf_size(). The only reason that the default value is 0
// is as a workaround for bugs in the way that some compilers handle
......@@ -248,17 +255,23 @@ public: // Basic types
public: // Iterators
#ifndef __STL_NON_TYPE_TMPL_PARAM_BUG
typedef __deque_iterator<value_type, reference, BufSiz> iterator;
typedef __deque_iterator<value_type, const_reference, BufSiz> const_iterator;
typedef __deque_iterator<T, T&, T*, BufSiz> iterator;
typedef __deque_iterator<T, const T&, const T&, BufSiz> const_iterator;
#else /* __STL_NON_TYPE_TMPL_PARAM_BUG */
typedef __deque_iterator<value_type, reference> iterator;
typedef __deque_iterator<value_type, const_reference> const_iterator;
typedef __deque_iterator<T, T&, T*> iterator;
typedef __deque_iterator<T, const T&, const T*> const_iterator;
#endif /* __STL_NON_TYPE_TMPL_PARAM_BUG */
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
typedef reverse_iterator<const_iterator, value_type, const_reference,
difference_type>
const_reverse_iterator;
typedef reverse_iterator<iterator, value_type, reference, difference_type>
reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
protected: // Internal typedefs
typedef pointer* map_pointer;
......@@ -553,19 +566,6 @@ protected: // Internal construction/destruction
void range_initialize(ForwardIterator first, ForwardIterator last,
forward_iterator_tag);
template <class BidirectionalIterator>
void range_initialize(BidirectionalIterator first,
BidirectionalIterator last,
bidirectional_iterator_tag) {
range_initialize(first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void range_initialize(RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
range_initialize(first, last, forward_iterator_tag());
}
#endif /* __STL_MEMBER_TEMPLATES */
protected: // Internal push_* and pop_*
......@@ -587,19 +587,6 @@ protected: // Internal insert functions
void insert(iterator pos, ForwardIterator first, ForwardIterator last,
forward_iterator_tag);
template <class BidirectionalIterator>
void insert(iterator pos,
BidirectionalIterator first, BidirectionalIterator last,
bidirectional_iterator_tag) {
insert(pos, first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void insert(iterator pos,
RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
insert(pos, first, last, forward_iterator_tag());
}
#endif /* __STL_MEMBER_TEMPLATES */
iterator insert_aux(iterator pos, const value_type& x);
......@@ -881,7 +868,7 @@ void deque<T, Alloc, BufSize>::fill_initialize(size_type n,
}
catch(...) {
for (map_pointer n = start.node; n < cur; ++n)
destroy(*cur, *cur + buffer_size());
destroy(*n, *n + buffer_size());
destroy_map_and_nodes();
throw;
}
......
......@@ -123,7 +123,6 @@ struct __hashtable_iterator {
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef Value& reference;
typedef const Value& const_reference;
typedef Value* pointer;
node* cur;
......@@ -132,6 +131,9 @@ struct __hashtable_iterator {
__hashtable_iterator(node* n, hashtable* tab) : cur(n), ht(tab) {}
__hashtable_iterator() {}
reference operator*() const { return cur->val; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
iterator& operator++();
iterator operator++(int);
bool operator==(const iterator& it) const { return cur == it.cur; }
......@@ -156,9 +158,8 @@ struct __hashtable_const_iterator {
typedef Value value_type;
typedef ptrdiff_t difference_type;
typedef size_t size_type;
typedef Value& reference;
typedef const Value& const_reference;
typedef Value* pointer;
typedef const Value& reference;
typedef const Value* pointer;
const node* cur;
const hashtable* ht;
......@@ -167,7 +168,10 @@ struct __hashtable_const_iterator {
: cur(n), ht(tab) {}
__hashtable_const_iterator() {}
__hashtable_const_iterator(const iterator& it) : cur(it.cur), ht(it.ht) {}
const_reference operator*() const { return cur->val; }
reference operator*() const { return cur->val; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
const_iterator& operator++();
const_iterator operator++(int);
bool operator==(const const_iterator& it) const { return cur == it.cur; }
......@@ -399,34 +403,6 @@ public:
insert_equal_noresize(*f);
}
template <class BidirectionalIterator>
void insert_unique(BidirectionalIterator f, BidirectionalIterator l,
bidirectional_iterator_tag)
{
insert_unique(f, l, forward_iterator_tag());
}
template <class BidirectionalIterator>
void insert_equal(BidirectionalIterator f, BidirectionalIterator l,
bidirectional_iterator_tag)
{
insert_equal(f, l, forward_iterator_tag());
}
template <class RandomAccessIterator>
void insert_unique(RandomAccessIterator f, RandomAccessIterator l,
random_access_iterator_tag)
{
insert_unique(f, l, forward_iterator_tag());
}
template <class RandomAccessIterator>
void insert_equal(RandomAccessIterator f, RandomAccessIterator l,
random_access_iterator_tag)
{
insert_equal(f, l, forward_iterator_tag());
}
#else /* __STL_MEMBER_TEMPLATES */
void insert_unique(const value_type* f, const value_type* l)
{
......@@ -619,6 +595,7 @@ __hashtable_const_iterator<V, K, HF, ExK, EqK, A>::operator++(int)
return tmp;
}
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
template <class V, class K, class HF, class ExK, class EqK, class All>
inline forward_iterator_tag
......@@ -661,6 +638,8 @@ distance_type(const __hashtable_const_iterator<V, K, HF, ExK, EqK, All>&)
return (hashtable<V, K, HF, ExK, EqK, All>::difference_type*) 0;
}
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
template <class V, class K, class HF, class Ex, class Eq, class A>
bool operator==(const hashtable<V, K, HF, Ex, Eq, A>& ht1,
const hashtable<V, K, HF, Ex, Eq, A>& ht2)
......
......@@ -40,17 +40,16 @@ struct __list_node {
T data;
};
template<class T, class Ref>
template<class T, class Ref, class Ptr>
struct __list_iterator {
typedef __list_iterator<T, T&> iterator;
typedef __list_iterator<T, const T&> const_iterator;
typedef __list_iterator<T, Ref> self;
typedef __list_iterator<T, T&, T*> iterator;
typedef __list_iterator<T, const T&, const T*> const_iterator;
typedef __list_iterator<T, Ref, Ptr> self;
typedef bidirectional_iterator_tag iterator_category;
typedef T value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef Ptr pointer;
typedef Ref reference;
typedef __list_node<T>* link_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
......@@ -63,7 +62,11 @@ struct __list_iterator {
bool operator==(const self& x) const { return node == x.node; }
bool operator!=(const self& x) const { return node != x.node; }
Ref operator*() const { return (*node).data; }
reference operator*() const { return (*node).data; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
self& operator++() {
node = (link_type)((*node).next);
......@@ -85,25 +88,27 @@ struct __list_iterator {
}
};
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
template <class T, class Ref>
template <class T, class Ref, class Ptr>
inline bidirectional_iterator_tag
iterator_category(const __list_iterator<T, Ref>&) {
iterator_category(const __list_iterator<T, Ref, Ptr>&) {
return bidirectional_iterator_tag();
}
template <class T, class Ref>
template <class T, class Ref, class Ptr>
inline T*
value_type(const __list_iterator<T, Ref>&) {
value_type(const __list_iterator<T, Ref, Ptr>&) {
return 0;
}
template <class T, class Ref>
template <class T, class Ref, class Ptr>
inline ptrdiff_t*
distance_type(const __list_iterator<T, Ref>&) {
distance_type(const __list_iterator<T, Ref, Ptr>&) {
return 0;
}
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
template <class T, class Alloc = alloc>
class list {
......@@ -121,15 +126,20 @@ public:
typedef ptrdiff_t difference_type;
public:
typedef __list_iterator<T, T&> iterator;
typedef __list_iterator<T, const T&> const_iterator;
typedef __list_iterator<T, T&, T*> iterator;
typedef __list_iterator<T, const T&, const T*> const_iterator;
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
typedef reverse_bidirectional_iterator<const_iterator, value_type,
const_reference, difference_type>
const_reverse_iterator;
typedef reverse_bidirectional_iterator<iterator, value_type, reference,
difference_type>
reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
protected:
link_type get_node() { return list_node_allocator::allocate(); }
......
......@@ -99,24 +99,27 @@ struct __slist_iterator_base
}
};
template <class T, class Ref>
template <class T, class Ref, class Ptr>
struct __slist_iterator : public __slist_iterator_base
{
typedef __slist_iterator<T, T&> iterator;
typedef __slist_iterator<T, const T&> const_iterator;
typedef __slist_iterator<T, Ref> self;
typedef __slist_iterator<T, T&, T*> iterator;
typedef __slist_iterator<T, const T&, const T*> const_iterator;
typedef __slist_iterator<T, Ref, Ptr> self;
typedef T value_type;
typedef value_type* pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef Ptr pointer;
typedef Ref reference;
typedef __slist_node<T> list_node;
__slist_iterator(list_node* x) : __slist_iterator_base(x) {}
__slist_iterator() : __slist_iterator_base(0) {}
__slist_iterator(const iterator& x) : __slist_iterator_base(x.node) {}
Ref operator*() const { return ((list_node*) node)->data; }
reference operator*() const { return ((list_node*) node)->data; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
self& operator++()
{
incr();
......@@ -130,6 +133,8 @@ struct __slist_iterator : public __slist_iterator_base
}
};
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
inline ptrdiff_t*
distance_type(const __slist_iterator_base&)
{
......@@ -142,12 +147,14 @@ iterator_category(const __slist_iterator_base&)
return forward_iterator_tag();
}
template <class T, class Ref>
template <class T, class Ref, class Ptr>
inline T*
value_type(const __slist_iterator<T, Ref>&) {
value_type(const __slist_iterator<T, Ref, Ptr>&) {
return 0;
}
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
inline size_t __slist_size(__slist_node_base* node)
{
size_t result = 0;
......@@ -167,8 +174,8 @@ public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef __slist_iterator<T, reference> iterator;
typedef __slist_iterator<T, const_reference> const_iterator;
typedef __slist_iterator<T, T&, T*> iterator;
typedef __slist_iterator<T, const T&, const T*> const_iterator;
private:
typedef __slist_node<T> list_node;
......
......@@ -47,14 +47,16 @@
// (9) Defines __STL_NON_TYPE_TMPL_PARAM_BUG if the compiler has
// trouble performing function template argument deduction for
// non-type template parameters.
// (10) Defines __STL_USE_EXCEPTIONS if the compiler (in the current
// compilation mode) supports exceptions.
// (11) Defines __STL_SGI_THREADS if this is being compiled on an SGI
// compiler, and if the user hasn't selected pthreads or no threads
// instead.
// (12) Defines __STL_WIN32THREADS if this is being compiled on a
// (10) Defines __SGI_STL_NO_ARROW_OPERATOR if the compiler is unable
// to support the -> operator for iterators.
// (11) Defines __STL_USE_EXCEPTIONS if the compiler (in the current
// compilation mode) supports exceptions.
// (12) Defines __STL_SGI_THREADS if this is being compiled on an SGI
// compiler, and if the user hasn't selected pthreads or no threads
// instead.
// (13) Defines __STL_WIN32THREADS if this is being compiled on a
// WIN32 compiler in multithreaded mode.
// (13) Defines __stl_assert either as a test or as a null macro,
// (14) Defines __stl_assert either as a test or as a null macro,
// depending on whether or not __STL_ASSERTIONS is defined.
# if defined(__sgi) && !defined(__GNUC__)
......@@ -120,6 +122,7 @@
# define __STL_NEED_EXPLICIT
# endif
# define __STL_NON_TYPE_TMPL_PARAM_BUG
# define __SGI_STL_NO_ARROW_OPERATOR
# ifdef _CPPUNWIND
# define __STL_USE_EXCEPTIONS
# endif
......@@ -132,6 +135,7 @@
# define __STL_NO_DRAND48
# define __STL_NEED_TYPENAME
# define __STL_LIMITED_DEFAULT_TEMPLATES
# define __SGI_STL_NO_ARROW_OPERATOR
# define __STL_NON_TYPE_TMPL_PARAM_BUG
# ifdef _CPPUNWIND
# define __STL_USE_EXCEPTIONS
......
......@@ -137,23 +137,25 @@ struct __rb_tree_base_iterator
}
};
template <class Value, class Ref>
template <class Value, class Ref, class Ptr>
struct __rb_tree_iterator : public __rb_tree_base_iterator
{
typedef Value value_type;
typedef Value& reference;
typedef const Value& const_reference;
typedef Value* pointer;
typedef __rb_tree_iterator<Value, reference> iterator;
typedef __rb_tree_iterator<Value, const_reference> const_iterator;
typedef __rb_tree_iterator<Value, Ref> self;
typedef __rb_tree_iterator<Value, Value&, Value*> iterator;
typedef __rb_tree_iterator<Value, const Value&, const Value*> const_iterator;
typedef __rb_tree_iterator<Value, Ref, Ptr> self;
typedef __rb_tree_node<Value>* link_type;
__rb_tree_iterator() {}
__rb_tree_iterator(link_type x) { node = x; }
__rb_tree_iterator(const iterator& it) { node = it.node; }
Ref operator*() const { return link_type(node)->value_field; }
reference operator*() const { return link_type(node)->value_field; }
#ifndef __SGI_STL_NO_ARROW_OPERATOR
pointer operator->() const { return &(operator*()); }
#endif /* __SGI_STL_NO_ARROW_OPERATOR */
self& operator++() { increment(); return *this; }
self operator++(int) {
......@@ -180,6 +182,8 @@ inline bool operator!=(const __rb_tree_base_iterator& x,
return x.node != y.node;
}
#ifndef __STL_CLASS_PARTIAL_SPECIALIZATION
inline bidirectional_iterator_tag
iterator_category(const __rb_tree_base_iterator&) {
return bidirectional_iterator_tag();
......@@ -190,11 +194,13 @@ distance_type(const __rb_tree_base_iterator&) {
return (__rb_tree_base_iterator::difference_type*) 0;
}
template <class Value, class Ref>
inline Value* value_type(const __rb_tree_iterator<Value, Ref>&) {
template <class Value, class Ref, class Ptr>
inline Value* value_type(const __rb_tree_iterator<Value, Ref, Ptr>&) {
return (Value*) 0;
}
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
inline void
__rb_tree_rotate_left(__rb_tree_node_base* x, __rb_tree_node_base*& root)
{
......@@ -487,15 +493,21 @@ protected:
}
public:
typedef __rb_tree_iterator<value_type, reference> iterator;
typedef __rb_tree_iterator<value_type, const_reference> const_iterator;
typedef __rb_tree_iterator<value_type, reference, pointer> iterator;
typedef __rb_tree_iterator<value_type, const_reference, const_pointer>
const_iterator;
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
typedef reverse_bidirectional_iterator<iterator, value_type, reference,
difference_type>
reverse_iterator;
typedef reverse_bidirectional_iterator<const_iterator, value_type,
const_reference, difference_type>
const_reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
private:
iterator __insert(base_ptr x, base_ptr y, const value_type& v);
link_type __copy(link_type x, link_type p);
......
......@@ -42,10 +42,16 @@ public:
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
#ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
typedef reverse_iterator<const_iterator> const_reverse_iterator;
typedef reverse_iterator<iterator> reverse_iterator;
#else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
typedef reverse_iterator<const_iterator, value_type, const_reference,
difference_type> const_reverse_iterator;
typedef reverse_iterator<iterator, value_type, reference, difference_type>
reverse_iterator;
#endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
protected:
typedef simple_alloc<value_type, Alloc> data_allocator;
iterator start;
......@@ -256,20 +262,6 @@ protected:
end_of_storage = finish;
}
template <class BidirectionalIterator>
void range_initialize(BidirectionalIterator first,
BidirectionalIterator last,
bidirectional_iterator_tag) {
range_initialize(first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void range_initialize(RandomAccessIterator first,
RandomAccessIterator last,
random_access_iterator_tag) {
range_initialize(first, last, forward_iterator_tag());
}
template <class InputIterator>
void range_insert(iterator pos,
InputIterator first, InputIterator last,
......@@ -280,19 +272,6 @@ protected:
ForwardIterator first, ForwardIterator last,
forward_iterator_tag);
template <class BidirectionalIterator>
void range_insert(iterator pos,
BidirectionalIterator first, BidirectionalIterator last,
bidirectional_iterator_tag) {
range_insert(pos, first, last, forward_iterator_tag());
}
template <class RandomAccessIterator>
void range_insert(iterator pos,
RandomAccessIterator first, RandomAccessIterator last,
random_access_iterator_tag) {
range_insert(pos, first, last, forward_iterator_tag());
}
#endif /* __STL_MEMBER_TEMPLATES */
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment