1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/pointers/_vector.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,238 @@
1.4 +/*
1.5 + * Copyright (c) 2003
1.6 + * Francois Dumont
1.7 + *
1.8 + * This material is provided "as is", with absolutely no warranty expressed
1.9 + * or implied. Any use is at your own risk.
1.10 + *
1.11 + * Permission to use or copy this software for any purpose is hereby granted
1.12 + * without fee, provided the above notices are retained on all copies.
1.13 + * Permission to modify the code and to distribute modified code is granted,
1.14 + * provided the above notices are retained, and a notice that the code was
1.15 + * modified is included with the above copyright notice.
1.16 + *
1.17 + */
1.18 +
1.19 +/* NOTE: This is an internal header file, included by other STL headers.
1.20 + * You should not attempt to use it directly.
1.21 + */
1.22 +
1.23 +#ifndef _STLP_SPECIALIZED_VECTOR_H
1.24 +#define _STLP_SPECIALIZED_VECTOR_H
1.25 +
1.26 +#ifndef _STLP_POINTERS_SPEC_TOOLS_H
1.27 +# include <stl/pointers/_tools.h>
1.28 +#endif
1.29 +
1.30 +_STLP_BEGIN_NAMESPACE
1.31 +
1.32 +#define VECTOR_IMPL _STLP_PTR_IMPL_NAME(vector)
1.33 +
1.34 +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
1.35 +_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV _Vector_base<void*,allocator<void*> >;
1.36 +_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV VECTOR_IMPL<void*, allocator<void*> >;
1.37 +#endif
1.38 +
1.39 +#if defined (_STLP_DEBUG)
1.40 +# define vector _STLP_NON_DBG_NAME(vector)
1.41 +_STLP_MOVE_TO_PRIV_NAMESPACE
1.42 +#endif
1.43 +
1.44 +template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
1.45 +class vector
1.46 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector)
1.47 + : public __stlport_class<vector<_Tp, _Alloc> >
1.48 +#endif
1.49 +{
1.50 + /* In the vector implementation iterators are pointer which give a number
1.51 + * of opportunities for optimization. To not break those optimizations
1.52 + * iterators passed to template should not be wrapped for casting purpose.
1.53 + * So vector implementation will always use a qualified void pointer type and
1.54 + * won't use iterator wrapping.
1.55 + */
1.56 + typedef typename _STLP_PRIV _StorageType<_Tp>::_QualifiedType _StorageType;
1.57 + typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
1.58 + typedef _STLP_PRIV VECTOR_IMPL<_StorageType, _StorageTypeAlloc> _Base;
1.59 + typedef vector<_Tp, _Alloc> _Self;
1.60 +
1.61 + typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
1.62 +
1.63 +public:
1.64 + typedef _Tp value_type;
1.65 + typedef value_type* pointer;
1.66 + typedef const value_type* const_pointer;
1.67 + typedef value_type* iterator;
1.68 + typedef const value_type* const_iterator;
1.69 + typedef value_type& reference;
1.70 + typedef const value_type& const_reference;
1.71 + typedef size_t size_type;
1.72 + typedef ptrdiff_t difference_type;
1.73 + typedef random_access_iterator_tag _Iterator_category;
1.74 +
1.75 + _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
1.76 + _STLP_FORCE_ALLOCATORS(value_type, _Alloc)
1.77 + typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
1.78 +
1.79 + allocator_type get_allocator() const
1.80 + { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
1.81 +
1.82 + iterator begin() { return cast_traits::to_value_type_ptr(_M_impl.begin()); }
1.83 + const_iterator begin() const { return cast_traits::to_value_type_cptr(_M_impl.begin()); }
1.84 + iterator end() { return cast_traits::to_value_type_ptr(_M_impl.end()); }
1.85 + const_iterator end() const { return cast_traits::to_value_type_cptr(_M_impl.end()); }
1.86 +
1.87 + reverse_iterator rbegin() { return reverse_iterator(end()); }
1.88 + const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
1.89 + reverse_iterator rend() { return reverse_iterator(begin()); }
1.90 + const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
1.91 +
1.92 + size_type size() const { return _M_impl.size(); }
1.93 + size_type max_size() const { return _M_impl.max_size(); }
1.94 +
1.95 + size_type capacity() const { return _M_impl.capacity(); }
1.96 + bool empty() const { return _M_impl.empty(); }
1.97 +
1.98 + reference operator[](size_type __n) { return cast_traits::to_value_type_ref(_M_impl[__n]); }
1.99 + const_reference operator[](size_type __n) const { return cast_traits::to_value_type_cref(_M_impl[__n]); }
1.100 +
1.101 + reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
1.102 + const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
1.103 + reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); }
1.104 + const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); }
1.105 +
1.106 + reference at(size_type __n) { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
1.107 + const_reference at(size_type __n) const { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
1.108 +
1.109 + explicit vector(const allocator_type& __a = allocator_type())
1.110 + : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
1.111 +
1.112 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
1.113 + explicit vector(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
1.114 +#else
1.115 + vector(size_type __n, const value_type& __val,
1.116 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
1.117 + const allocator_type& __a = allocator_type())
1.118 + : _M_impl(__n, cast_traits::to_storage_type_cref(__val),
1.119 + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
1.120 +
1.121 +#if defined(_STLP_DONT_SUP_DFLT_PARAM)
1.122 + explicit vector(size_type __n)
1.123 + : _M_impl(__n, allocator_type() ) {}
1.124 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
1.125 +
1.126 + vector(const _Self& __x)
1.127 + : _M_impl(__x._M_impl) {}
1.128 +
1.129 + explicit vector(__move_source<_Self> src)
1.130 + : _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
1.131 +
1.132 +#if defined (_STLP_MEMBER_TEMPLATES)
1.133 + template <class _InputIterator>
1.134 + vector(_InputIterator __first, _InputIterator __last,
1.135 + const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL )
1.136 + : _M_impl(__first, __last,
1.137 + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
1.138 +
1.139 +# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
1.140 + template <class _InputIterator>
1.141 + vector(_InputIterator __first, _InputIterator __last)
1.142 + : _M_impl(__first, __last) {}
1.143 +# endif
1.144 +
1.145 +#else
1.146 + vector(const_iterator __first, const_iterator __last,
1.147 + const allocator_type& __a = allocator_type())
1.148 + : _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last),
1.149 + _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
1.150 +#endif /* _STLP_MEMBER_TEMPLATES */
1.151 +
1.152 + _Self& operator=(const _Self& __x) { _M_impl = __x._M_impl; return *this; }
1.153 +
1.154 + void reserve(size_type __n) {_M_impl.reserve(__n);}
1.155 + void assign(size_type __n, const value_type& __val)
1.156 + { _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
1.157 +
1.158 +#if defined (_STLP_MEMBER_TEMPLATES)
1.159 + template <class _InputIterator>
1.160 + void assign(_InputIterator __first, _InputIterator __last)
1.161 + { _M_impl.assign(__first, __last); }
1.162 +#else
1.163 + void assign(const_iterator __first, const_iterator __last) {
1.164 + _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
1.165 + cast_traits::to_storage_type_cptr(__last));
1.166 + }
1.167 +#endif /* _STLP_MEMBER_TEMPLATES */
1.168 +
1.169 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
1.170 + void push_back(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
1.171 +#else
1.172 + void push_back(const value_type& __x)
1.173 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
1.174 + { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); }
1.175 +
1.176 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
1.177 + iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
1.178 +#else
1.179 + iterator insert(iterator __pos, const value_type& __x)
1.180 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
1.181 + { return cast_traits::to_value_type_ptr(_M_impl.insert(cast_traits::to_storage_type_ptr(__pos),
1.182 + cast_traits::to_storage_type_cref(__x))); }
1.183 +
1.184 +#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
1.185 + void push_back() { _M_impl.push_back(); }
1.186 + iterator insert(iterator __pos)
1.187 + { return _M_impl.insert(cast_traits::to_storage_type_ptr(__pos)); }
1.188 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
1.189 +
1.190 + void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
1.191 +
1.192 +#if defined (_STLP_MEMBER_TEMPLATES)
1.193 + template <class _InputIterator>
1.194 + void insert(iterator __pos, _InputIterator __first, _InputIterator __last)
1.195 + { _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __first, __last); }
1.196 +#else
1.197 + void insert(iterator __pos, const_iterator __first, const_iterator __last) {
1.198 + _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), cast_traits::to_storage_type_cptr(__first),
1.199 + cast_traits::to_storage_type_cptr(__last));
1.200 + }
1.201 +#endif
1.202 +
1.203 + void insert (iterator __pos, size_type __n, const value_type& __x) {
1.204 + _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __n, cast_traits::to_storage_type_cref(__x));
1.205 + }
1.206 +
1.207 + void pop_back() {_M_impl.pop_back();}
1.208 + iterator erase(iterator __pos)
1.209 + {return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__pos)));}
1.210 + iterator erase(iterator __first, iterator __last) {
1.211 + return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__first),
1.212 + cast_traits::to_storage_type_ptr(__last)));
1.213 + }
1.214 +
1.215 +#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
1.216 + void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
1.217 +#else
1.218 + void resize(size_type __new_size, const value_type& __x)
1.219 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
1.220 + { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
1.221 +
1.222 +#if defined(_STLP_DONT_SUP_DFLT_PARAM)
1.223 + void resize(size_type __new_size) { _M_impl.resize(__new_size); }
1.224 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
1.225 +
1.226 + void clear() { _M_impl.clear(); }
1.227 +
1.228 +private:
1.229 + _Base _M_impl;
1.230 +};
1.231 +
1.232 +#if defined (vector)
1.233 +# undef vector
1.234 +_STLP_MOVE_TO_STD_NAMESPACE
1.235 +#endif
1.236 +
1.237 +#undef VECTOR_IMPL
1.238 +
1.239 +_STLP_END_NAMESPACE
1.240 +
1.241 +#endif /* _STLP_SPECIALIZED_VECTOR_H */