epoc32/include/tools/stlport/stl/pointers/_deque.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/pointers/_deque.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,379 @@
     1.4 +/*
     1.5 + * Copyright (c) 2004
     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_DEQUE_H
    1.24 +#define _STLP_SPECIALIZED_DEQUE_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 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.32 +
    1.33 +/*
    1.34 + * struct helper to cast deque iterators:
    1.35 + */
    1.36 +template <class _StorageT, class _ValueT>
    1.37 +struct _DequeIteCast {
    1.38 +  typedef _Deque_iterator<_ValueT, _Nonconst_traits<_ValueT> > iterator;
    1.39 +  typedef _Deque_iterator<_ValueT, _Const_traits<_ValueT> >    const_iterator;
    1.40 +  typedef _Deque_iterator<_StorageT, _Nonconst_traits<_StorageT> > storage_iterator;
    1.41 +  typedef _Deque_iterator<_StorageT, _Const_traits<_StorageT> > const_storage_iterator;
    1.42 +  typedef _CastTraits<_StorageT, _ValueT> cast_traits;
    1.43 +
    1.44 +  static iterator to_value_type_ite (storage_iterator const& __ite) {
    1.45 +    iterator tmp;
    1.46 +    tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
    1.47 +    tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
    1.48 +    tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
    1.49 +    tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
    1.50 +    return tmp;
    1.51 +  }
    1.52 +  static storage_iterator to_storage_type_ite (iterator const& __ite) {
    1.53 +    storage_iterator tmp;
    1.54 +    tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
    1.55 +    tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
    1.56 +    tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
    1.57 +    tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
    1.58 +    return tmp;
    1.59 +  }
    1.60 +
    1.61 +  static const_iterator to_value_type_cite (const_storage_iterator const& __ite) {
    1.62 +    const_iterator tmp;
    1.63 +    tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
    1.64 +    tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
    1.65 +    tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
    1.66 +    tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
    1.67 +    return tmp;
    1.68 +  }
    1.69 +
    1.70 +  static const_storage_iterator to_storage_type_cite (const_iterator const& __ite) {
    1.71 +    const_storage_iterator tmp;
    1.72 +    tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
    1.73 +    tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
    1.74 +    tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
    1.75 +    tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
    1.76 +    return tmp;
    1.77 +  }
    1.78 +};
    1.79 +
    1.80 +#define DEQUE_IMPL _STLP_PTR_IMPL_NAME(deque)
    1.81 +
    1.82 +#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
    1.83 +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<size_t, void*,  allocator<void*> >;
    1.84 +_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void***, void**,  allocator<void**> >;
    1.85 +_STLP_EXPORT template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
    1.86 +_STLP_EXPORT_TEMPLATE_CLASS _Deque_base<void*,allocator<void*> >;
    1.87 +_STLP_EXPORT_TEMPLATE_CLASS DEQUE_IMPL<void*,allocator<void*> >;
    1.88 +#endif
    1.89 +
    1.90 +#if defined (_STLP_DEBUG)
    1.91 +#  define deque _STLP_NON_DBG_NAME(deque)
    1.92 +#else
    1.93 +_STLP_MOVE_TO_STD_NAMESPACE
    1.94 +#endif
    1.95 +
    1.96 +template <class _Tp, _STLP_DEFAULT_ALLOCATOR_SELECT(_Tp) >
    1.97 +class deque
    1.98 +#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque)
    1.99 +            : public __stlport_class<deque<_Tp, _Alloc> >
   1.100 +#endif
   1.101 +{
   1.102 +  typedef typename _STLP_PRIV _StorageType<_Tp>::_Type _StorageType;
   1.103 +  typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
   1.104 +  typedef _STLP_PRIV DEQUE_IMPL<_StorageType, _StorageTypeAlloc> _Base;
   1.105 +  typedef deque<_Tp, _Alloc> _Self;
   1.106 +
   1.107 +  typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
   1.108 +  typedef _STLP_PRIV _DequeIteCast<_StorageType, _Tp> ite_cast_traits;
   1.109 +
   1.110 +public:
   1.111 +  typedef _Tp value_type;
   1.112 +  typedef value_type* pointer;
   1.113 +  typedef const value_type* const_pointer;
   1.114 +  typedef value_type& reference;
   1.115 +  typedef const value_type& const_reference;
   1.116 +  typedef size_t size_type;
   1.117 +  typedef ptrdiff_t difference_type;
   1.118 +  typedef random_access_iterator_tag _Iterator_category;
   1.119 +  _STLP_FORCE_ALLOCATORS(value_type, _Alloc)
   1.120 +  typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
   1.121 +  typedef _STLP_PRIV _Deque_iterator<value_type, _Nonconst_traits<value_type> > iterator;
   1.122 +  typedef _STLP_PRIV _Deque_iterator<value_type, _Const_traits<value_type> >    const_iterator;
   1.123 +
   1.124 +  _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
   1.125 +
   1.126 +public:                         // Basic accessors
   1.127 +  iterator begin() { return ite_cast_traits::to_value_type_ite(_M_impl.begin()); }
   1.128 +  iterator end()   { return ite_cast_traits::to_value_type_ite(_M_impl.end()); }
   1.129 +  const_iterator begin() const { return ite_cast_traits::to_value_type_cite(_M_impl.begin()); }
   1.130 +  const_iterator end() const   { return ite_cast_traits::to_value_type_cite(_M_impl.end()); }
   1.131 +
   1.132 +  reverse_iterator rbegin() { return reverse_iterator(end()); }
   1.133 +  reverse_iterator rend()   { return reverse_iterator(begin()); }
   1.134 +  const_reverse_iterator rbegin() const
   1.135 +  { return const_reverse_iterator(end()); }
   1.136 +  const_reverse_iterator rend() const
   1.137 +  { return const_reverse_iterator(begin()); }
   1.138 +
   1.139 +  reference operator[](size_type __n)
   1.140 +  { return cast_traits::to_value_type_ref(_M_impl[__n]); }
   1.141 +  const_reference operator[](size_type __n) const
   1.142 +  { return cast_traits::to_value_type_cref(_M_impl[__n]); }
   1.143 +
   1.144 +  reference at(size_type __n)
   1.145 +  { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
   1.146 +  const_reference at(size_type __n) const
   1.147 +  { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
   1.148 +
   1.149 +  reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
   1.150 +  reference back()  { return cast_traits::to_value_type_ref(_M_impl.back()); }
   1.151 +  const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
   1.152 +  const_reference back() const  { return cast_traits::to_value_type_cref(_M_impl.back()); }
   1.153 +
   1.154 +  size_type size() const     { return _M_impl.size(); }
   1.155 +  size_type max_size() const { return _M_impl.max_size(); }
   1.156 +  bool empty() const         { return _M_impl.empty(); }
   1.157 +  allocator_type get_allocator() const { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
   1.158 +
   1.159 +  explicit deque(const allocator_type& __a = allocator_type())
   1.160 +    : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
   1.161 +
   1.162 +  deque(const _Self& __x) : _M_impl(__x._M_impl) {}
   1.163 +
   1.164 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.165 +  explicit deque(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
   1.166 +#else
   1.167 +  deque(size_type __n, const value_type& __val,
   1.168 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.169 +        const allocator_type& __a = allocator_type())
   1.170 +    : _M_impl(__n, cast_traits::to_storage_type_cref(__val), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
   1.171 +  // int,long variants may be needed
   1.172 +#if defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.173 +  explicit deque(size_type __n) : _M_impl(__n) {}
   1.174 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.175 +
   1.176 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.177 +  template <class _InputIterator>
   1.178 +  deque(_InputIterator __first, _InputIterator __last,
   1.179 +        const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
   1.180 +#if !defined (_STLP_USE_ITERATOR_WRAPPER)
   1.181 +  : _M_impl(__first, __last,
   1.182 +            _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
   1.183 +#else
   1.184 +  : _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
   1.185 +#endif
   1.186 +#if defined (_STLP_USE_ITERATOR_WRAPPER)
   1.187 +    insert(end(), __first, __last);
   1.188 +#endif
   1.189 +  }
   1.190 +
   1.191 +#  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
   1.192 +  template <class _InputIterator>
   1.193 +  deque(_InputIterator __first, _InputIterator __last)
   1.194 +#    if !defined (_STLP_USE_ITERATOR_WRAPPER)
   1.195 +    : _M_impl(__first, __last) {}
   1.196 +#    else
   1.197 +  { insert(end(), __first, __last); }
   1.198 +#    endif
   1.199 +#  endif
   1.200 +
   1.201 +#else
   1.202 +  deque(const_pointer __first, const_pointer __last,
   1.203 +        const allocator_type& __a = allocator_type() )
   1.204 +    : _M_impl(cast_traits::to_storage_type_cptr(__first),
   1.205 +              cast_traits::to_storage_type_cptr(__last),
   1.206 +              _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
   1.207 +
   1.208 +  deque(const_iterator __first, const_iterator __last,
   1.209 +        const allocator_type& __a = allocator_type() )
   1.210 +    : _M_impl(ite_cast_traits::to_storage_type_cite(__first),
   1.211 +              ite_cast_traits::to_storage_type_cite(__last),
   1.212 +              _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
   1.213 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.214 +
   1.215 +  deque(__move_source<_Self> src)
   1.216 +    : _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
   1.217 +
   1.218 +  _Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; }
   1.219 +
   1.220 +  void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
   1.221 +
   1.222 +  void assign(size_type __n, const value_type& __val) {
   1.223 +    _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val));
   1.224 +  }
   1.225 +
   1.226 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.227 +#  if defined (_STLP_USE_ITERATOR_WRAPPER)
   1.228 +private:
   1.229 +  template <class _Integer>
   1.230 +  void _M_assign_dispatch(_Integer __n, _Integer __val,
   1.231 +                          const __true_type&)
   1.232 +  { _M_impl.assign(__n, __val); }
   1.233 +
   1.234 +  template <class _InputIterator>
   1.235 +  void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
   1.236 +                          const __false_type&) {
   1.237 +    _M_impl.assign(typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
   1.238 +                   typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
   1.239 +  }
   1.240 +
   1.241 +public:
   1.242 +#  endif
   1.243 +  template <class _InputIterator>
   1.244 +  void assign(_InputIterator __first, _InputIterator __last) {
   1.245 +#  if defined (_STLP_USE_ITERATOR_WRAPPER)
   1.246 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.247 +    _M_assign_dispatch(__first, __last, _Integral());
   1.248 +#  else
   1.249 +    _M_impl.assign(__first, __last);
   1.250 +#  endif
   1.251 +  }
   1.252 +#else
   1.253 +  void assign(const_pointer __first, const_pointer __last)
   1.254 +  { _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
   1.255 +                   cast_traits::to_storage_type_cptr(__last)); }
   1.256 +  void assign(const_iterator __first, const_iterator __last)
   1.257 +  { _M_impl.assign(ite_cast_traits::to_storage_type_cite(__first),
   1.258 +                   ite_cast_traits::to_storage_type_cite(__last)); }
   1.259 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.260 +
   1.261 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.262 +  void push_back(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
   1.263 +#else
   1.264 +  void push_back(const value_type& __t)
   1.265 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.266 +  { _M_impl.push_back(cast_traits::to_storage_type_cref(__t)); }
   1.267 +
   1.268 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.269 +  void push_front(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
   1.270 +#else
   1.271 +  void push_front(const value_type& __t)
   1.272 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.273 +  { _M_impl.push_front(cast_traits::to_storage_type_cref(__t)); }
   1.274 +
   1.275 +# if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.276 +  void push_back()  { _M_impl.push_back(); }
   1.277 +  void push_front() { _M_impl.push_front(); }
   1.278 +# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.279 +
   1.280 +  void pop_back()  { _M_impl.pop_back(); }
   1.281 +  void pop_front() { _M_impl.pop_front(); }
   1.282 +
   1.283 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.284 +  iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
   1.285 +#else
   1.286 +  iterator insert(iterator __pos, const value_type& __x)
   1.287 +#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.288 +  { return ite_cast_traits::to_value_type_ite(_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
   1.289 +                                                             cast_traits::to_storage_type_cref(__x))); }
   1.290 +
   1.291 +#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
   1.292 +  iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
   1.293 +#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
   1.294 +
   1.295 +  void insert(iterator __pos, size_type __n, const value_type& __x)
   1.296 +  { _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, cast_traits::to_storage_type_cref(__x)); }
   1.297 +
   1.298 +#if defined (_STLP_MEMBER_TEMPLATES)
   1.299 +#  if defined (_STLP_USE_ITERATOR_WRAPPER)
   1.300 +private:
   1.301 +  template <class _Integer>
   1.302 +  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
   1.303 +                          const __true_type&) {
   1.304 +    _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, __val);
   1.305 +  }
   1.306 +
   1.307 +  template <class _InputIterator>
   1.308 +  void _M_insert_dispatch(iterator __pos,
   1.309 +                          _InputIterator __first, _InputIterator __last,
   1.310 +                          const __false_type&) {
   1.311 +    _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
   1.312 +                   typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
   1.313 +                   typename _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
   1.314 +  }
   1.315 +
   1.316 +public:
   1.317 +#  endif
   1.318 +
   1.319 +  template <class _InputIterator>
   1.320 +  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
   1.321 +#  if defined (_STLP_USE_ITERATOR_WRAPPER)
   1.322 +    // Check whether it's an integral type.  If so, it's not an iterator.
   1.323 +    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
   1.324 +    _M_insert_dispatch(__pos, __first, __last, _Integral());
   1.325 +#  else
   1.326 +    _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __first, __last);
   1.327 +#  endif
   1.328 +  }
   1.329 +
   1.330 +#else /* _STLP_MEMBER_TEMPLATES */
   1.331 +  void insert(iterator __pos,
   1.332 +              const_pointer __first, const_pointer __last) {
   1.333 +    _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
   1.334 +                   cast_traits::to_storage_type_cptr(__first),
   1.335 +                   cast_traits::to_storage_type_cptr(__last));
   1.336 +  }
   1.337 +  void insert(iterator __pos,
   1.338 +              const_iterator __first, const_iterator __last) {
   1.339 +    _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
   1.340 +                   ite_cast_traits::to_storage_type_cite(__first),
   1.341 +                   ite_cast_traits::to_storage_type_cite(__last));
   1.342 +  }
   1.343 +
   1.344 +#endif /* _STLP_MEMBER_TEMPLATES */
   1.345 +
   1.346 +#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.347 +  void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
   1.348 +#else
   1.349 +  void resize(size_type __new_size, const value_type& __x)
   1.350 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.351 +  { _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
   1.352 +
   1.353 +#if defined (_STLP_DONT_SUP_DFLT_PARAM)
   1.354 +  void resize(size_type __new_size) { _M_impl.resize(__new_size); }
   1.355 +#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
   1.356 +
   1.357 +  iterator erase(iterator __pos)
   1.358 +  { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__pos))); }
   1.359 +
   1.360 +  iterator erase(iterator __first, iterator __last)
   1.361 +  { return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__first),
   1.362 +                                                            ite_cast_traits::to_storage_type_ite(__last))); }
   1.363 +  void clear() { _M_impl.clear(); }
   1.364 +
   1.365 +private:
   1.366 +  _Base _M_impl;
   1.367 +};
   1.368 +
   1.369 +#if defined (deque)
   1.370 +#  undef deque
   1.371 +_STLP_MOVE_TO_STD_NAMESPACE
   1.372 +#endif
   1.373 +
   1.374 +#undef DEQUE_IMPL
   1.375 +
   1.376 +_STLP_END_NAMESPACE
   1.377 +
   1.378 +#endif /* _STLP_SPECIALIZED_DEQUE_H */
   1.379 +
   1.380 +// Local Variables:
   1.381 +// mode:C++
   1.382 +// End: