first commit

This commit is contained in:
Jose Caban
2025-06-07 11:34:38 -04:00
commit 0eb2d7c07d
4708 changed files with 1500614 additions and 0 deletions

View File

@@ -0,0 +1,390 @@
/*
* Copyright (c) 2004
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_SPECIALIZED_DEQUE_H
#define _STLP_SPECIALIZED_DEQUE_H
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
# include <stl/pointers/_tools.h>
#endif
_STLP_BEGIN_NAMESPACE
_STLP_MOVE_TO_PRIV_NAMESPACE
/*
* struct helper to cast deque iterators:
*/
template <class _StorageT, class _ValueT>
struct _DequeIteCast {
typedef _Deque_iterator<_ValueT, _Nonconst_traits<_ValueT> > iterator;
typedef _Deque_iterator<_ValueT, _Const_traits<_ValueT> > const_iterator;
typedef _Deque_iterator<_StorageT, _Nonconst_traits<_StorageT> > storage_iterator;
typedef _Deque_iterator<_StorageT, _Const_traits<_StorageT> > const_storage_iterator;
typedef _CastTraits<_StorageT, _ValueT> cast_traits;
static iterator to_value_type_ite (storage_iterator const& __ite) {
iterator tmp;
tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
return tmp;
}
static storage_iterator to_storage_type_ite (iterator const& __ite) {
storage_iterator tmp;
tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
return tmp;
}
static const_iterator to_value_type_cite (const_storage_iterator const& __ite) {
const_iterator tmp;
tmp._M_cur = cast_traits::to_value_type_ptr(__ite._M_cur);
tmp._M_first = cast_traits::to_value_type_ptr(__ite._M_first);
tmp._M_last = cast_traits::to_value_type_ptr(__ite._M_last);
tmp._M_node = cast_traits::to_value_type_pptr(__ite._M_node);
return tmp;
}
static const_storage_iterator to_storage_type_cite (const_iterator const& __ite) {
const_storage_iterator tmp;
tmp._M_cur = cast_traits::to_storage_type_ptr(__ite._M_cur);
tmp._M_first = cast_traits::to_storage_type_ptr(__ite._M_first);
tmp._M_last = cast_traits::to_storage_type_ptr(__ite._M_last);
tmp._M_node = cast_traits::to_storage_type_pptr(__ite._M_node);
return tmp;
}
};
#define DEQUE_IMPL _STLP_PTR_IMPL_NAME(deque)
#if defined (__BORLANDC__) || defined (__DMC__)
# define typename
#endif
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<size_t, void*, allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void***, void**, allocator<void**> >;
_STLP_EXPORT template struct _STLP_CLASS_DECLSPEC _Deque_iterator<void*, _Nonconst_traits<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS _Deque_base<void*,allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS DEQUE_IMPL<void*,allocator<void*> >;
#endif
#if defined (_STLP_DEBUG)
# define deque _STLP_NON_DBG_NAME(deque)
#else
_STLP_MOVE_TO_STD_NAMESPACE
#endif
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
class deque
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (deque)
: public __stlport_class<deque<_Tp, _Alloc> >
#endif
{
typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType;
typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV DEQUE_IMPL<_StorageType, _StorageTypeAlloc> _Base;
typedef deque<_Tp, _Alloc> _Self;
typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
typedef _STLP_PRIV _DequeIteCast<_StorageType, _Tp> ite_cast_traits;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag _Iterator_category;
_STLP_FORCE_ALLOCATORS(value_type, _Alloc)
typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
typedef _STLP_PRIV _Deque_iterator<value_type, _Nonconst_traits<value_type> > iterator;
typedef _STLP_PRIV _Deque_iterator<value_type, _Const_traits<value_type> > const_iterator;
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
public: // Basic accessors
iterator begin() { return ite_cast_traits::to_value_type_ite(_M_impl.begin()); }
iterator end() { return ite_cast_traits::to_value_type_ite(_M_impl.end()); }
const_iterator begin() const { return ite_cast_traits::to_value_type_cite(_M_impl.begin()); }
const_iterator end() const { return ite_cast_traits::to_value_type_cite(_M_impl.end()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const
{ return const_reverse_iterator(end()); }
const_reverse_iterator rend() const
{ return const_reverse_iterator(begin()); }
reference operator[](size_type __n)
{ return cast_traits::to_value_type_ref(_M_impl[__n]); }
const_reference operator[](size_type __n) const
{ return cast_traits::to_value_type_cref(_M_impl[__n]); }
reference at(size_type __n)
{ return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
const_reference at(size_type __n) const
{ return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); }
const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); }
size_type size() const { return _M_impl.size(); }
size_type max_size() const { return _M_impl.max_size(); }
bool empty() const { return _M_impl.empty(); }
allocator_type get_allocator() const { return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
explicit deque(const allocator_type& __a = allocator_type())
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
deque(const _Self& __x) : _M_impl(__x._M_impl) {}
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
explicit deque(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
#else
deque(size_type __n, const value_type& __val,
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
const allocator_type& __a = allocator_type())
: _M_impl(__n, cast_traits::to_storage_type_cref(__val), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
// int,long variants may be needed
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
explicit deque(size_type __n) : _M_impl(__n) {}
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
deque(_InputIterator __first, _InputIterator __last,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
#if !defined (_STLP_USE_ITERATOR_WRAPPER)
: _M_impl(__first, __last,
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
#else
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
#endif
#if defined (_STLP_USE_ITERATOR_WRAPPER)
insert(end(), __first, __last);
#endif
}
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
deque(_InputIterator __first, _InputIterator __last)
# if !defined (_STLP_USE_ITERATOR_WRAPPER)
: _M_impl(__first, __last) {}
# else
{ insert(end(), __first, __last); }
# endif
# endif
#else
deque(const_pointer __first, const_pointer __last,
const allocator_type& __a = allocator_type() )
: _M_impl(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
deque(const_iterator __first, const_iterator __last,
const allocator_type& __a = allocator_type() )
: _M_impl(ite_cast_traits::to_storage_type_cite(__first),
ite_cast_traits::to_storage_type_cite(__last),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#endif /* _STLP_MEMBER_TEMPLATES */
#if !defined (_STLP_NO_MOVE_SEMANTIC)
deque(__move_source<_Self> src)
: _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
#endif
_Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; }
void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
void assign(size_type __n, const value_type& __val) {
_M_impl.assign(__n, cast_traits::to_storage_type_cref(__val));
}
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __val,
const __true_type&)
{ _M_impl.assign(__n, __val); }
template <class _InputIterator>
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_assign_dispatch(__first, __last, _Integral());
# else
_M_impl.assign(__first, __last);
# endif
}
#else
void assign(const_pointer __first, const_pointer __last)
{ _M_impl.assign(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last)); }
void assign(const_iterator __first, const_iterator __last)
{ _M_impl.assign(ite_cast_traits::to_storage_type_cite(__first),
ite_cast_traits::to_storage_type_cite(__last)); }
#endif /* _STLP_MEMBER_TEMPLATES */
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
void push_back(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void push_back(const value_type& __t)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ _M_impl.push_back(cast_traits::to_storage_type_cref(__t)); }
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
void push_front(const value_type& __t = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void push_front(const value_type& __t)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ _M_impl.push_front(cast_traits::to_storage_type_cref(__t)); }
# if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
void push_back() { _M_impl.push_back(); }
void push_front() { _M_impl.push_front(); }
# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
void pop_back() { _M_impl.pop_back(); }
void pop_front() { _M_impl.pop_front(); }
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
iterator insert(iterator __pos, const value_type& __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ return ite_cast_traits::to_value_type_ite(_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
cast_traits::to_storage_type_cref(__x))); }
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
void insert(iterator __pos, size_type __n, const value_type& __x)
{ _M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, cast_traits::to_storage_type_cref(__x)); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
const __true_type&) {
_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __n, __val);
}
template <class _InputIterator>
void _M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_insert_dispatch(__pos, __first, __last, _Integral());
# else
_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos), __first, __last);
# endif
}
#else /* _STLP_MEMBER_TEMPLATES */
void insert(iterator __pos,
const_pointer __first, const_pointer __last) {
_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
void insert(iterator __pos,
const_iterator __first, const_iterator __last) {
_M_impl.insert(ite_cast_traits::to_storage_type_ite(__pos),
ite_cast_traits::to_storage_type_cite(__first),
ite_cast_traits::to_storage_type_cite(__last));
}
#endif /* _STLP_MEMBER_TEMPLATES */
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void resize(size_type __new_size, const value_type& __x)
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
{ _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size) { _M_impl.resize(__new_size); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
iterator erase(iterator __pos)
{ return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__pos))); }
iterator erase(iterator __first, iterator __last)
{ return ite_cast_traits::to_value_type_ite(_M_impl.erase(ite_cast_traits::to_storage_type_ite(__first),
ite_cast_traits::to_storage_type_ite(__last))); }
void clear() { _M_impl.clear(); }
private:
_Base _M_impl;
};
#if defined (deque)
# undef deque
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#undef DEQUE_IMPL
#if defined (__BORLANDC__) || defined (__DMC__)
# undef typename
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_SPECIALIZED_DEQUE_H */
// Local Variables:
// mode:C++
// End:

View File

@@ -0,0 +1,345 @@
/*
* Copyright (c) 2003
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_PTR_SPECIALIZED_LIST_H
#define _STLP_PTR_SPECIALIZED_LIST_H
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
# include <stl/pointers/_tools.h>
#endif
_STLP_BEGIN_NAMESPACE
#define LIST_IMPL _STLP_PTR_IMPL_NAME(list)
#if defined (__BORLANDC__) || defined (__DMC__)
# define typename
#endif
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS _List_node<void*>;
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS allocator<_STLP_PRIV _List_node<void*> >;
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_List_node_base, _List_node<void*>, allocator<_List_node<void*> > >;
_STLP_EXPORT_TEMPLATE_CLASS _List_base<void*, allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS LIST_IMPL<void*, allocator<void*> >;
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#if defined (_STLP_DEBUG)
# define list _STLP_NON_DBG_NAME(list)
_STLP_MOVE_TO_PRIV_NAMESPACE
#endif
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
class list
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (list)
: public __stlport_class<list<_Tp, _Alloc> >
#endif
{
typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType;
typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV LIST_IMPL<_StorageType, _StorageTypeAlloc> _Base;
typedef typename _Base::iterator _BaseIte;
typedef typename _Base::const_iterator _BaseConstIte;
typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
typedef list<_Tp, _Alloc> _Self;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
_STLP_FORCE_ALLOCATORS(value_type, _Alloc)
typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
typedef bidirectional_iterator_tag _Iterator_category;
typedef _STLP_PRIV _List_iterator<value_type, _Nonconst_traits<value_type> > iterator;
typedef _STLP_PRIV _List_iterator<value_type, _Const_traits<value_type> > const_iterator;
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
allocator_type get_allocator() const
{ return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
explicit list(const allocator_type& __a = allocator_type())
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit list(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
#else
list(size_type __n, const value_type& __val,
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
const allocator_type& __a = allocator_type())
: _M_impl(__n, cast_traits::to_storage_type_cref(__val),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit list(size_type __n)
: _M_impl(__n) {}
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
list(_InputIterator __first, _InputIterator __last,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
# if !defined (_STLP_USE_ITERATOR_WRAPPER)
: _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
# else
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
insert(begin(), __first, __last);
}
# endif
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
list(_InputIterator __first, _InputIterator __last)
# if !defined (_STLP_USE_WRAPPER_ITERATOR)
: _M_impl(__first, __last) {}
# else
{ insert(begin(), __first, __last); }
# endif
# endif
#else /* _STLP_MEMBER_TEMPLATES */
list(const value_type *__first, const value_type *__last,
const allocator_type& __a = allocator_type())
: _M_impl(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
list(const_iterator __first, const_iterator __last,
const allocator_type& __a = allocator_type())
: _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#endif /* _STLP_MEMBER_TEMPLATES */
list(const _Self& __x) : _M_impl(__x._M_impl) {}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
list(__move_source<_Self> src)
: _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
#endif
iterator begin() { return iterator(_M_impl.begin()._M_node); }
const_iterator begin() const { return const_iterator(_M_impl.begin()._M_node); }
iterator end() { return iterator(_M_impl.end()._M_node); }
const_iterator end() const { return const_iterator(_M_impl.end()._M_node); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
bool empty() const { return _M_impl.empty(); }
size_type size() const { return _M_impl.size(); }
size_type max_size() const { return _M_impl.max_size(); }
reference front() { return *begin(); }
const_reference front() const { return *begin(); }
reference back() { return *(--end()); }
const_reference back() const { return *(--end()); }
void swap(_Self &__x) { _M_impl.swap(__x._M_impl); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
void clear() { _M_impl.clear(); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
iterator insert(iterator __pos, const_reference __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
iterator insert(iterator __pos, const_reference __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ return iterator(_M_impl.insert(_BaseIte(__pos._M_node),
cast_traits::to_storage_type_cref(__x))._M_node); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
const __true_type&)
{ _M_impl.insert(_BaseIte(__pos._M_node), __n, __val); }
template <class _InputIterator>
void _M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.insert(_BaseIte(__pos._M_node),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_insert_dispatch(__pos, __first, __last, _Integral());
# else
_M_impl.insert(_BaseIte(__pos._M_node), __first, __last);
# endif
}
#else /* _STLP_MEMBER_TEMPLATES */
void insert(iterator __pos, const value_type *__first, const value_type *__last)
{ _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last)); }
void insert(iterator __pos, const_iterator __first, const_iterator __last)
{ _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
#endif /* _STLP_MEMBER_TEMPLATES */
void insert(iterator __pos, size_type __n, const value_type& __x)
{ _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); }
void push_front(const value_type& __x) { _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); }
void push_back(const value_type& __x) { _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); }
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
iterator insert(iterator __pos) { return iterator(_M_impl.insert(__pos._M_node)._M_node); }
void push_front() { _M_impl.push_front();}
void push_back() { _M_impl.push_back();}
# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
iterator erase(iterator __pos)
{ return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); }
iterator erase(iterator __first, iterator __last)
{ return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void resize(size_type __new_size) { _M_impl.resize(__new_size); }
void resize(size_type __new_size, const value_type& __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/
{_M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));}
void pop_front() { _M_impl.pop_front(); }
void pop_back() { _M_impl.pop_back(); }
_Self& operator=(const _Self& __x)
{ _M_impl = __x._M_impl; return *this; }
void assign(size_type __n, const value_type& __val)
{ _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)
{ _M_impl.assign(__n, __val); }
template <class _InputIterator>
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_assign_dispatch(__first, __last, _Integral());
# else
_M_impl.assign(__first, __last);
# endif
}
#else
void assign(const value_type *__first, const value_type *__last) {
_M_impl.assign(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
void assign(const_iterator __first, const_iterator __last)
{ _M_impl.assign(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
#endif
void splice(iterator __pos, _Self& __x)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); }
void splice(iterator __pos, _Self& __x, iterator __i)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); }
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl,
_BaseIte(__first._M_node), _BaseIte(__last._M_node)); }
void remove(const_reference __val)
{ _M_impl.remove(cast_traits::to_storage_type_cref(__val)); }
void unique() { _M_impl.unique(); }
void merge(_Self& __x) { _M_impl.merge(__x._M_impl); }
void reverse() { _M_impl.reverse(); }
void sort() { _M_impl.sort(); }
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _Predicate>
void remove_if(_Predicate __pred)
{ _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); }
template <class _BinaryPredicate>
void unique(_BinaryPredicate __bin_pred)
{ _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__bin_pred)); }
template <class _StrictWeakOrdering>
void merge(_Self &__x, _StrictWeakOrdering __comp)
{ _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); }
template <class _StrictWeakOrdering>
void sort(_StrictWeakOrdering __comp)
{ _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); }
#endif /* _STLP_MEMBER_TEMPLATES */
private:
_Base _M_impl;
};
#if defined (list)
# undef list
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#undef LIST_IMPL
#if defined (__BORLANDC__) || defined (__DMC__)
# undef typename
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_PTR_SPECIALIZED_LIST_H */
// Local Variables:
// mode:C++
// End:

View File

@@ -0,0 +1,564 @@
/*
* Copyright (c) 2005
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_PTR_SPECIALIZED_SET_H
#define _STLP_PTR_SPECIALIZED_SET_H
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
# include <stl/pointers/_tools.h>
#endif
_STLP_BEGIN_NAMESPACE
#if defined (__BORLANDC__) || defined (__DMC__)
# define typename
#endif
//Specific iterator traits creation
_STLP_CREATE_ITERATOR_TRAITS(SetTraitsT, Const_traits)
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_EXPORT template struct _STLP_CLASS_DECLSPEC less<void*>;
_STLP_MOVE_TO_PRIV_NAMESPACE
typedef _Rb_tree_node<void*> _Node;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Rb_tree_node_base, _Node, allocator<_Node> >;
_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree_base<void*, allocator<void*> >;
# if defined (_STLP_DEBUG)
_STLP_EXPORT_TEMPLATE_CLASS _DbgCompare<void*, less<void*> >;
# define _Rb_tree _STLP_NON_DBG_NAME(Rb_tree)
_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree<void*, _DbgCompare<void*, less<void*> >, void*, _Identity<void*>,
_SetTraitsT<void*>, allocator<void*> >;
# undef _Rb_tree
# endif
_STLP_EXPORT_TEMPLATE_CLASS _Rb_tree<void*, less<void*>, void*, _Identity<void*>,
_SetTraitsT<void*>, allocator<void*> >;
_STLP_MOVE_TO_STD_NAMESPACE
#endif
template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) >
class set
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
: public __stlport_class<set<_Key, _Compare, _Alloc> >
#endif
{
#if !defined (__BORLANDC__)
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes;
typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType;
typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType;
#else
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_KeyStorageType _KeyStorageType;
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_CompareStorageType _CompareStorageType;
#endif
typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits;
typedef set<_Key, _Compare, _Alloc> _Self;
public:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
protected:
//Specific iterator traits creation
typedef _STLP_PRIV _SetTraitsT<value_type> _SetTraits;
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
value_type, _STLP_PRIV _Identity<value_type>,
_SetTraits, _Alloc> _Priv_Rep_type;
typedef _STLP_PRIV _SetTraitsT<_KeyStorageType> _SetStorageTraits;
public:
//dums: need the following public for the __move_traits framework
typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType,
_KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>,
_SetStorageTraits, _StorageTypeAlloc> _Rep_type;
private:
typedef typename _Rep_type::iterator base_iterator;
typedef typename _Rep_type::const_iterator const_base_iterator;
public:
typedef typename _Priv_Rep_type::pointer pointer;
typedef typename _Priv_Rep_type::const_pointer const_pointer;
typedef typename _Priv_Rep_type::reference reference;
typedef typename _Priv_Rep_type::const_reference const_reference;
typedef typename _Priv_Rep_type::iterator iterator;
typedef typename _Priv_Rep_type::const_iterator const_iterator;
typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator;
typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Priv_Rep_type::size_type size_type;
typedef typename _Priv_Rep_type::difference_type difference_type;
typedef typename _Priv_Rep_type::allocator_type allocator_type;
private:
_Rep_type _M_t; // red-black tree representing set
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
#if defined (_STLP_DEBUG)
static iterator _S_to_value_ite(const_base_iterator __ite)
{ return iterator(__ite._Owner(), __ite._M_iterator._M_node); }
static base_iterator _S_to_storage_ite(const_iterator __ite)
{ return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); }
#else
static iterator _S_to_value_ite(const_base_iterator __ite)
{ return iterator(__ite._M_node); }
static base_iterator _S_to_storage_ite(const_iterator __ite)
{ return base_iterator(__ite._M_node); }
#endif
public:
set() : _M_t(_CompareStorageType(), _StorageTypeAlloc()) {}
explicit set(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {}
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
set(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), _StorageTypeAlloc()) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_unique(__first, __last);
# endif
}
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp)
: _M_t(__comp, _StorageTypeAlloc()) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_unique(__first, __last);
# endif
}
# endif
template <class _InputIterator>
set(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_unique(__first, __last);
# endif
}
#else
set(const value_type* __first, const value_type* __last)
: _M_t(_Compare(), _StorageTypeAlloc()) {
_M_t.insert_unique(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
set(const value_type* __first, const value_type* __last,
const _Compare& __comp, const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {
_M_t.insert_unique(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
set(const_iterator __first, const_iterator __last)
: _M_t(_Compare(), _StorageTypeAlloc())
{ _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
set(const_iterator __first, const_iterator __last,
const _Compare& __comp, const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType))
{ _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
#endif /* _STLP_MEMBER_TEMPLATES */
set(const _Self& __x) : _M_t(__x._M_t) {}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
set(__move_source<_Self> src)
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
#endif
_Self& operator=(const _Self& __x) {
_M_t = __x._M_t;
return *this;
}
// accessors:
key_compare key_comp() const { return _M_t.key_comp(); }
value_compare value_comp() const { return _M_t.key_comp(); }
allocator_type get_allocator() const
{ return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); }
iterator begin() { return _S_to_value_ite(_M_t.begin()); }
iterator end() { return _S_to_value_ite(_M_t.end()); }
const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); }
const_iterator end() const { return _S_to_value_ite(_M_t.end()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
bool empty() const { return _M_t.empty(); }
size_type size() const { return _M_t.size(); }
size_type max_size() const { return _M_t.max_size(); }
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
// insert/erase
pair<iterator,bool> insert(const value_type& __x) {
pair<base_iterator, bool> ret = _M_t.insert_unique(cast_traits::to_storage_type_cref(__x));
return pair<iterator, bool>(_S_to_value_ite(ret.first), ret.second);
}
iterator insert(iterator __pos, const value_type& __x)
{ return _S_to_value_ite(_M_t.insert_unique(_S_to_storage_ite(__pos), cast_traits::to_storage_type_cref(__x))); }
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_unique(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_unique(__first, __last);
# endif
}
#else
void insert(const_iterator __first, const_iterator __last)
{ _M_t.insert_unique(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
void insert(const value_type* __first, const value_type* __last) {
_M_t.insert_unique(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
#endif
void erase(iterator __pos)
{ _M_t.erase(_S_to_storage_ite(__pos)); }
size_type erase(const key_type& __x)
{ return _M_t.erase_unique(cast_traits::to_storage_type_cref(__x)); }
void erase(iterator __first, iterator __last)
{ _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
void clear() { _M_t.clear(); }
// set operations:
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator find(const _KT& __x) const
{ return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
iterator find(const _KT& __x)
{ return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
size_type count(const _KT& __x) const
{ return _M_t.find(cast_traits::to_storage_type_crefT(__x)) == _M_t.end() ? 0 : 1; }
_STLP_TEMPLATE_FOR_CONT_EXT
iterator lower_bound(const _KT& __x)
{ return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator lower_bound(const _KT& __x) const
{ return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
iterator upper_bound(const _KT& __x)
{ return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator upper_bound(const _KT& __x) const
{ return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
pair<iterator, iterator> equal_range(const _KT& __x) {
pair<base_iterator, base_iterator> __ret;
__ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x));
return pair<iterator, iterator>(_S_to_value_ite(__ret.first),
_S_to_value_ite(__ret.second));
}
_STLP_TEMPLATE_FOR_CONT_EXT
pair<const_iterator, const_iterator> equal_range(const _KT& __x) const {
pair<const_base_iterator, const_base_iterator> __ret;
__ret = _M_t.equal_range_unique(cast_traits::to_storage_type_crefT(__x));
return pair<const_iterator, const_iterator>(_S_to_value_ite(__ret.first),
_S_to_value_ite(__ret.second));
}
};
//Specific iterator traits creation
_STLP_CREATE_ITERATOR_TRAITS(MultisetTraitsT, Const_traits)
template <class _Key, _STLP_DFL_TMPL_PARAM(_Compare, less<_Key>),
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Key>) >
class multiset
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
: public __stlport_class<multiset<_Key, _Compare, _Alloc> >
#endif
{
#if !defined (__BORLANDC__)
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare> _AssocStorageTypes;
typedef typename _AssocStorageTypes::_KeyStorageType _KeyStorageType;
typedef typename _AssocStorageTypes::_CompareStorageType _CompareStorageType;
#else
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_KeyStorageType _KeyStorageType;
typedef _STLP_PRIV _AssocStorageTypes<_Key, _Compare>::_CompareStorageType _CompareStorageType;
#endif
typedef typename _Alloc_traits<_KeyStorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV _CastTraits<_KeyStorageType, _Key> cast_traits;
typedef multiset<_Key, _Compare, _Alloc> _Self;
public:
// typedefs:
typedef _Key key_type;
typedef _Key value_type;
typedef _Compare key_compare;
typedef _Compare value_compare;
protected:
//Specific iterator traits creation
typedef _STLP_PRIV _MultisetTraitsT<value_type> _MultisetTraits;
typedef _STLP_PRIV _Rb_tree<key_type, key_compare,
value_type, _STLP_PRIV _Identity<value_type>,
_MultisetTraits, _Alloc> _Priv_Rep_type;
typedef _STLP_PRIV _MultisetTraitsT<_KeyStorageType> _MultisetStorageTraits;
public:
//dums: need the following public for the __move_traits framework
typedef _STLP_PRIV _Rb_tree<_KeyStorageType, _CompareStorageType,
_KeyStorageType, _STLP_PRIV _Identity<_KeyStorageType>,
_MultisetStorageTraits, _StorageTypeAlloc> _Rep_type;
private:
typedef typename _Rep_type::iterator base_iterator;
typedef typename _Rep_type::const_iterator const_base_iterator;
public:
typedef typename _Priv_Rep_type::pointer pointer;
typedef typename _Priv_Rep_type::const_pointer const_pointer;
typedef typename _Priv_Rep_type::reference reference;
typedef typename _Priv_Rep_type::const_reference const_reference;
typedef typename _Priv_Rep_type::iterator iterator;
typedef typename _Priv_Rep_type::const_iterator const_iterator;
typedef typename _Priv_Rep_type::reverse_iterator reverse_iterator;
typedef typename _Priv_Rep_type::const_reverse_iterator const_reverse_iterator;
typedef typename _Priv_Rep_type::size_type size_type;
typedef typename _Priv_Rep_type::difference_type difference_type;
typedef typename _Priv_Rep_type::allocator_type allocator_type;
private:
_Rep_type _M_t; // red-black tree representing multiset
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
#if defined (_STLP_DEBUG)
static iterator _S_to_value_ite(const_base_iterator __ite)
{ return iterator(__ite._Owner(), __ite._M_iterator._M_node); }
static base_iterator _S_to_storage_ite(const_iterator __ite)
{ return base_iterator(__ite._Owner(), __ite._M_iterator._M_node); }
#else
static iterator _S_to_value_ite(const_base_iterator __ite)
{ return iterator(__ite._M_node); }
static base_iterator _S_to_storage_ite(const_iterator __ite)
{ return base_iterator(__ite._M_node); }
#endif
public:
multiset() : _M_t(_Compare(), _StorageTypeAlloc()) {}
explicit multiset(const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {}
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
multiset(_InputIterator __first, _InputIterator __last)
: _M_t(_Compare(), _StorageTypeAlloc()) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_equal(__first, __last);
# endif
}
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp)
: _M_t(__comp, _StorageTypeAlloc()) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_equal(__first, __last);
# endif
}
# endif
template <class _InputIterator>
multiset(_InputIterator __first, _InputIterator __last,
const _Compare& __comp,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_equal(__first, __last);
# endif
}
#else
multiset(const value_type* __first, const value_type* __last)
: _M_t(_Compare(), _StorageTypeAlloc()) {
_M_t.insert_equal(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
multiset(const value_type* __first, const value_type* __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType)) {
_M_t.insert_equal(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
multiset(const_iterator __first, const_iterator __last)
: _M_t(_Compare(), _StorageTypeAlloc())
{ _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
multiset(const_iterator __first, const_iterator __last,
const _Compare& __comp,
const allocator_type& __a = allocator_type())
: _M_t(__comp, _STLP_CONVERT_ALLOCATOR(__a, _KeyStorageType))
{ _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
#endif /* _STLP_MEMBER_TEMPLATES */
multiset(const _Self& __x)
: _M_t(__x._M_t) {}
_Self& operator=(const _Self& __x) {
_M_t = __x._M_t;
return *this;
}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
multiset(__move_source<_Self> src)
: _M_t(__move_source<_Rep_type>(src.get()._M_t)) {}
#endif
// accessors:
key_compare key_comp() const { return _M_t.key_comp(); }
value_compare value_comp() const { return _M_t.key_comp(); }
allocator_type get_allocator() const
{ return _STLP_CONVERT_ALLOCATOR(_M_t.get_allocator(), value_type); }
iterator begin() { return _S_to_value_ite(_M_t.begin()); }
iterator end() { return _S_to_value_ite(_M_t.end()); }
const_iterator begin() const { return _S_to_value_ite(_M_t.begin()); }
const_iterator end() const { return _S_to_value_ite(_M_t.end()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
bool empty() const { return _M_t.empty(); }
size_type size() const { return _M_t.size(); }
size_type max_size() const { return _M_t.max_size(); }
void swap(_Self& __x) { _M_t.swap(__x._M_t); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
// insert/erase
iterator insert(const value_type& __x)
{ return _S_to_value_ite(_M_t.insert_equal(cast_traits::to_storage_type_cref(__x))); }
iterator insert(iterator __pos, const value_type& __x) {
return _S_to_value_ite(_M_t.insert_equal(_S_to_storage_ite(__pos),
cast_traits::to_storage_type_cref(__x)));
}
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
void insert(_InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
_M_t.insert_equal(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_KeyStorageType, _Key, _InputIterator>::_Ite(__last));
# else
_M_t.insert_equal(__first, __last);
# endif
}
#else
void insert(const value_type* __first, const value_type* __last) {
_M_t.insert_equal(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
void insert(const_iterator __first, const_iterator __last)
{ _M_t.insert_equal(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
#endif /* _STLP_MEMBER_TEMPLATES */
void erase(iterator __pos)
{ _M_t.erase(_S_to_storage_ite(__pos)); }
size_type erase(const key_type& __x)
{ return _M_t.erase(cast_traits::to_storage_type_cref(__x)); }
void erase(iterator __first, iterator __last)
{ _M_t.erase(_S_to_storage_ite(__first), _S_to_storage_ite(__last)); }
void clear() { _M_t.clear(); }
// multiset operations:
_STLP_TEMPLATE_FOR_CONT_EXT
iterator find(const _KT& __x)
{ return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator find(const _KT& __x) const
{ return _S_to_value_ite(_M_t.find(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
size_type count(const _KT& __x) const
{ return _M_t.count(cast_traits::to_storage_type_crefT(__x)); }
_STLP_TEMPLATE_FOR_CONT_EXT
iterator lower_bound(const _KT& __x)
{ return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator lower_bound(const _KT& __x) const
{ return _S_to_value_ite(_M_t.lower_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
iterator upper_bound(const _KT& __x)
{ return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
const_iterator upper_bound(const _KT& __x) const
{ return _S_to_value_ite(_M_t.upper_bound(cast_traits::to_storage_type_crefT(__x))); }
_STLP_TEMPLATE_FOR_CONT_EXT
pair<iterator, iterator> equal_range(const _KT& __x) {
pair<base_iterator, base_iterator> __ret;
__ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x));
return pair<iterator, iterator>(_S_to_value_ite(__ret.first),
_S_to_value_ite(__ret.second));
}
_STLP_TEMPLATE_FOR_CONT_EXT
pair<const_iterator, const_iterator> equal_range(const _KT& __x) const {
pair<const_base_iterator, const_base_iterator> __ret;
__ret = _M_t.equal_range(cast_traits::to_storage_type_crefT(__x));
return pair<const_iterator, const_iterator>(_S_to_value_ite(__ret.first),
_S_to_value_ite(__ret.second));
}
};
#if defined (__BORLANDC__) || defined (__DMC__)
# undef typename
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_PTR_SPECIALIZED_SET_H */
// Local Variables:
// mode:C++
// End:

View File

@@ -0,0 +1,427 @@
/*
* Copyright (c) 2003
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_SPECIALIZED_SLIST_H
#define _STLP_SPECIALIZED_SLIST_H
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
# include <stl/pointers/_tools.h>
#endif
_STLP_BEGIN_NAMESPACE
#define SLIST_IMPL _STLP_PTR_IMPL_NAME(slist)
#if defined (__BORLANDC__) || defined (__DMC__)
# define typename
#endif
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_MOVE_TO_PRIV_NAMESPACE
_STLP_EXPORT_TEMPLATE_CLASS _Slist_node<void*>;
typedef _Slist_node<void*> _VoidPtrSNode;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<_Slist_node_base, _VoidPtrSNode, allocator<_VoidPtrSNode> >;
_STLP_EXPORT_TEMPLATE_CLASS _Slist_base<void*, allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS SLIST_IMPL<void*, allocator<void*> >;
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#if defined (_STLP_DEBUG)
# define slist _STLP_NON_DBG_NAME(slist)
_STLP_MOVE_TO_PRIV_NAMESPACE
#endif
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
class slist
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (slist)
: public __stlport_class<slist<_Tp, _Alloc> >
#endif
{
typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_Type _StorageType;
typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV SLIST_IMPL<_StorageType, _StorageTypeAlloc> _Base;
typedef typename _Base::iterator _BaseIte;
typedef typename _Base::const_iterator _BaseConstIte;
typedef slist<_Tp, _Alloc> _Self;
typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
typedef _STLP_PRIV _Slist_node_base _Node_base;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef forward_iterator_tag _Iterator_category;
typedef _STLP_PRIV _Slist_iterator<value_type, _Nonconst_traits<value_type> > iterator;
typedef _STLP_PRIV _Slist_iterator<value_type, _Const_traits<value_type> > const_iterator;
_STLP_FORCE_ALLOCATORS(value_type, _Alloc)
typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
public:
allocator_type get_allocator() const
{ return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
explicit slist(const allocator_type& __a = allocator_type())
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit slist(size_type __n, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type),
#else
slist(size_type __n, const value_type& __x,
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
const allocator_type& __a = allocator_type())
: _M_impl(__n, cast_traits::to_storage_type_cref(__x), _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit slist(size_type __n) : _M_impl(__n) {}
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
#if defined (_STLP_MEMBER_TEMPLATES)
// We don't need any dispatching tricks here, because _M_insert_after_range
// already does them.
template <class _InputIterator>
slist(_InputIterator __first, _InputIterator __last,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
# if !defined (_STLP_USE_ITERATOR_WRAPPER)
: _M_impl(__first, __last, _STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
# else
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {
insert_after(before_begin(), __first, __last);
}
# endif
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
// VC++ needs this crazyness
template <class _InputIterator>
slist(_InputIterator __first, _InputIterator __last)
# if !defined (_STLP_USE_WRAPPER_ITERATOR)
: _M_impl(__first, __last) {}
# else
{ insert_after(before_begin(), __first, __last); }
# endif
# endif
#else /* _STLP_MEMBER_TEMPLATES */
slist(const_iterator __first, const_iterator __last,
const allocator_type& __a = allocator_type() )
: _M_impl(_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
slist(const value_type* __first, const value_type* __last,
const allocator_type& __a = allocator_type())
: _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#endif /* _STLP_MEMBER_TEMPLATES */
slist(const _Self& __x) : _M_impl(__x._M_impl) {}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
slist(__move_source<_Self> src)
: _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
#endif
_Self& operator= (const _Self& __x) { _M_impl = __x._M_impl; return *this; }
void assign(size_type __n, const value_type& __val)
{ _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_assign_dispatch(_Integer __n, _Integer __val,
const __true_type&)
{ _M_impl.assign(__n, __val); }
template <class _InputIterator>
void _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.assign(_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_assign_dispatch(__first, __last, _Integral());
# else
_M_impl.assign(__first, __last);
# endif
}
#else
void assign(const value_type *__first, const value_type *__last) {
_M_impl.assign(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
void assign(const_iterator __first, const_iterator __last) {
_M_impl.assign(_BaseConstIte(__first._M_node),
_BaseConstIte(__last._M_node));
}
#endif /* _STLP_MEMBER_TEMPLATES */
iterator before_begin() { return iterator(_M_impl.before_begin()._M_node); }
const_iterator before_begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.before_begin()._M_node)); }
iterator begin() { return iterator(_M_impl.begin()._M_node); }
const_iterator begin() const { return const_iterator(const_cast<_Node_base*>(_M_impl.begin()._M_node));}
iterator end() { return iterator(_M_impl.end()._M_node); }
const_iterator end() const { return iterator(_M_impl.end()._M_node); }
size_type size() const { return _M_impl.size(); }
size_type max_size() const { return _M_impl.max_size(); }
bool empty() const { return _M_impl.empty(); }
void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
public:
reference front() { return *begin(); }
const_reference front() const { return *begin(); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
void push_front(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void push_front(const value_type& __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ _M_impl.push_front(cast_traits::to_storage_type_cref(__x)); }
# if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
void push_front() { _M_impl.push_front();}
# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
void pop_front() { _M_impl.pop_front(); }
iterator previous(const_iterator __pos)
{ return iterator(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node); }
const_iterator previous(const_iterator __pos) const
{ return const_iterator(const_cast<_Node_base*>(_M_impl.previous(_BaseConstIte(__pos._M_node))._M_node)); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
iterator insert_after(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
iterator insert_after(iterator __pos, const value_type& __x)
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
{ return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node),
cast_traits::to_storage_type_cref(__x))._M_node); }
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
iterator insert_after(iterator __pos)
{ return iterator(_M_impl.insert_after(_BaseIte(__pos._M_node))._M_node);}
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
void insert_after(iterator __pos, size_type __n, const value_type& __x)
{ _M_impl.insert_after(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_insert_after_dispatch(iterator __pos, _Integer __n, _Integer __val,
const __true_type&) {
_M_impl.insert_after(_BaseIte(__pos._M_node), __n, __val);
}
template <class _InputIterator>
void _M_insert_after_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.insert_after(_BaseIte(__pos._M_node),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void insert_after(iterator __pos, _InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_insert_after_dispatch(__pos, __first, __last, _Integral());
# else
_M_impl.insert_after(_BaseIte(__pos._M_node), __first, __last);
# endif
}
#else /* _STLP_MEMBER_TEMPLATES */
void insert_after(iterator __pos,
const_iterator __first, const_iterator __last)
{ _M_impl.insert_after(_BaseIte(__pos._M_node),
_BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
void insert_after(iterator __pos,
const value_type* __first, const value_type* __last) {
_M_impl.insert_after(_BaseIte(__pos._M_node),
cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
#endif /* _STLP_MEMBER_TEMPLATES */
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
iterator insert(iterator __pos, const value_type& __x)
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
{ return iterator(_M_impl.insert(_BaseIte(__pos._M_node),
cast_traits::to_storage_type_cref(__x))._M_node); }
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
iterator insert(iterator __pos)
{ return iterator(_M_impl.insert(_BaseIte(__pos._M_node))._M_node); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
void insert(iterator __pos, size_type __n, const value_type& __x)
{ _M_impl.insert(_BaseIte(__pos._M_node), __n, cast_traits::to_storage_type_cref(__x)); }
#if defined (_STLP_MEMBER_TEMPLATES)
# if defined (_STLP_USE_ITERATOR_WRAPPER)
private:
template <class _Integer>
void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,
const __true_type&) {
_M_impl.insert(_BaseIte(__pos._M_node), __n, __val);
}
template <class _InputIterator>
void _M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last,
const __false_type&) {
_M_impl.insert(_BaseIte(__pos._M_node), _STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__first),
_STLP_TYPENAME _STLP_PRIV _IteWrapper<_StorageType, _Tp, _InputIterator>::_Ite(__last));
}
public:
# endif
template <class _InputIterator>
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
# if defined (_STLP_USE_ITERATOR_WRAPPER)
// Check whether it's an integral type. If so, it's not an iterator.
typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
_M_insert_dispatch(__pos, __first, __last, _Integral());
# else
_M_impl.insert(_BaseIte(__pos._M_node), __first, __last);
# endif
}
#else /* _STLP_MEMBER_TEMPLATES */
void insert(iterator __pos, const_iterator __first, const_iterator __last)
{ _M_impl.insert(_BaseIte(__pos._M_node), _BaseConstIte(__first._M_node), _BaseConstIte(__last._M_node)); }
void insert(iterator __pos, const value_type* __first, const value_type* __last)
{ _M_impl.insert(_BaseIte(__pos._M_node), cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last)); }
#endif /* _STLP_MEMBER_TEMPLATES */
iterator erase_after(iterator __pos)
{ return iterator(_M_impl.erase_after(_BaseIte(__pos._M_node))._M_node); }
iterator erase_after(iterator __before_first, iterator __last)
{ return iterator(_M_impl.erase_after(_BaseIte(__before_first._M_node),
_BaseIte(__last._M_node))._M_node); }
iterator erase(iterator __pos)
{ return iterator(_M_impl.erase(_BaseIte(__pos._M_node))._M_node); }
iterator erase(iterator __first, iterator __last)
{ return iterator(_M_impl.erase(_BaseIte(__first._M_node), _BaseIte(__last._M_node))._M_node); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void resize(size_type __new_size, const value_type& __x)
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
{ _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x));}
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size) { _M_impl.resize(__new_size); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
void clear() { _M_impl.clear(); }
void splice_after(iterator __pos, _Self& __x,
iterator __before_first, iterator __before_last)
{ _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl,
_BaseIte(__before_first._M_node), _BaseIte(__before_last._M_node)); }
void splice_after(iterator __pos, _Self& __x, iterator __prev)
{ _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__prev._M_node)); }
void splice_after(iterator __pos, _Self& __x)
{ _M_impl.splice_after(_BaseIte(__pos._M_node), __x._M_impl); }
void splice(iterator __pos, _Self& __x)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl); }
void splice(iterator __pos, _Self& __x, iterator __i)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl, _BaseIte(__i._M_node)); }
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last)
{ _M_impl.splice(_BaseIte(__pos._M_node), __x._M_impl,
_BaseIte(__first._M_node), _BaseIte(__last._M_node)); }
void reverse() { _M_impl.reverse(); }
void remove(const value_type& __val) { _M_impl.remove(cast_traits::to_storage_type_cref(__val)); }
void unique() { _M_impl.unique(); }
void merge(_Self& __x) { _M_impl.merge(__x._M_impl); }
void sort() {_M_impl.sort(); }
#ifdef _STLP_MEMBER_TEMPLATES
template <class _Predicate>
void remove_if(_Predicate __pred)
{ _M_impl.remove_if(_STLP_PRIV _UnaryPredWrapper<_StorageType, _Tp, _Predicate>(__pred)); }
template <class _BinaryPredicate>
void unique(_BinaryPredicate __pred)
{ _M_impl.unique(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _BinaryPredicate>(__pred)); }
template <class _StrictWeakOrdering>
void merge(_Self& __x, _StrictWeakOrdering __comp)
{ _M_impl.merge(__x._M_impl, _STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); }
template <class _StrictWeakOrdering>
void sort(_StrictWeakOrdering __comp)
{ _M_impl.sort(_STLP_PRIV _BinaryPredWrapper<_StorageType, _Tp, _StrictWeakOrdering>(__comp)); }
#endif /* _STLP_MEMBER_TEMPLATES */
private:
_Base _M_impl;
};
#if defined (slist)
# undef slist
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#undef SLIST_IMPL
#if defined (__BORLANDC__) || defined (__DMC__)
# undef typename
#endif
_STLP_END_NAMESPACE
#endif /* _STLP_SPECIALIZED_SLIST_H */
// Local Variables:
// mode:C++
// End:

View File

@@ -0,0 +1,471 @@
/*
* Copyright (c) 2003
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
#define _STLP_POINTERS_SPEC_TOOLS_H
#ifndef _STLP_TYPE_TRAITS_H
# include <stl/type_traits.h>
#endif
_STLP_BEGIN_NAMESPACE
//Some usefull declarations:
template <class _Tp> struct less;
_STLP_MOVE_TO_PRIV_NAMESPACE
template <class _StorageT, class _ValueT, class _BinaryPredicate>
struct _BinaryPredWrapper;
/*
* Since the compiler only allows at most one non-trivial
* implicit conversion we can make use of a shim class to
* be sure that functions below doesn't accept classes with
* implicit pointer conversion operators
*/
struct _VoidPointerShim
{ _VoidPointerShim(void*); };
struct _ConstVoidPointerShim
{ _ConstVoidPointerShim(const void*); };
struct _VolatileVoidPointerShim
{ _VolatileVoidPointerShim(volatile void*); };
struct _ConstVolatileVoidPointerShim
{ _ConstVolatileVoidPointerShim(const volatile void*); };
//The dispatch functions:
template <class _Tp>
char _UseVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&);
char _UseVoidPtrStorageType(const __true_type& /*POD*/, ...);
char* _UseVoidPtrStorageType(const __true_type& /*POD*/, _VoidPointerShim);
template <class _Tp>
char _UseConstVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&);
char _UseConstVoidPtrStorageType(const __true_type& /*POD*/, ...);
char* _UseConstVoidPtrStorageType(const __true_type& /*POD*/, _ConstVoidPointerShim);
template <class _Tp>
char _UseVolatileVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&);
char _UseVolatileVoidPtrStorageType(const __true_type& /*POD*/, ...);
char* _UseVolatileVoidPtrStorageType(const __true_type& /*POD*/, _VolatileVoidPointerShim);
template <class _Tp>
char _UseConstVolatileVoidPtrStorageType(const __false_type& /*POD*/, const _Tp&);
char _UseConstVolatileVoidPtrStorageType(const __true_type& /*POD*/, ...);
char* _UseConstVolatileVoidPtrStorageType(const __true_type& /*POD*/, _ConstVolatileVoidPointerShim);
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
/* Thanks to class partial specialization the pointer specialization feature can even be used in
* presence of incomplete type:
* struct MyStruct {
* typedef vector<MyStruct> MyStructContainer;
* typedef MyStructContainer::iterator MyStructIterator;
* };
*/
template <class _Tp>
struct _StorageType {
typedef _Tp _QualifiedType;
typedef _Tp _Type;
enum { use_const_volatile_void_ptr = 0 };
};
template <class _Tp>
struct _StorageType<_Tp*> {
// Even if we detect a pointer type we use dispatch function to consider if it can be stored as a void*.
// For instance function pointer might not necessarily be convertible to void*.
enum { use_void_ptr = (sizeof(_UseVoidPtrStorageType(__true_type(),
__STATIC_CAST(_Tp*, 0))) == sizeof(char*)) };
enum { use_const_volatile_void_ptr = use_void_ptr };
typedef typename __select<use_void_ptr,
void*,
_Tp*>::_Ret _QualifiedType;
typedef _QualifiedType _Type;
};
template <class _Tp>
struct _StorageType<_Tp const*> {
enum { use_void_ptr = (sizeof(_UseConstVoidPtrStorageType(__true_type(),
__STATIC_CAST(const _Tp*, 0))) == sizeof(char*)) };
enum { use_const_volatile_void_ptr = use_void_ptr };
typedef typename __select<use_void_ptr,
const void*,
const _Tp*>::_Ret _QualifiedType;
typedef typename __select<use_void_ptr,
void*,
const _Tp*>::_Ret _Type;
};
template <class _Tp>
struct _StorageType<_Tp volatile*> {
enum { use_void_ptr = (sizeof(_UseVolatileVoidPtrStorageType(__true_type(),
__STATIC_CAST(_Tp volatile*, 0))) == sizeof(char*)) };
enum { use_const_volatile_void_ptr = use_void_ptr };
typedef typename __select<use_void_ptr,
volatile void*,
volatile _Tp*>::_Ret _QualifiedType;
typedef typename __select<use_void_ptr,
void*,
volatile _Tp*>::_Ret _Type;
};
template <class _Tp>
struct _StorageType<_Tp const volatile*> {
enum { use_void_ptr = (sizeof(_UseConstVolatileVoidPtrStorageType(__true_type(),
__STATIC_CAST(_Tp const volatile*, 0))) == sizeof(char*)) };
enum { use_const_volatile_void_ptr = use_void_ptr };
typedef typename __select<use_void_ptr,
const volatile void*,
const volatile _Tp*>::_Ret _QualifiedType;
typedef typename __select<use_void_ptr,
void*,
const volatile _Tp*>::_Ret _Type;
};
#else
template <class _Tp>
struct _StorageType {
typedef typename __type_traits<_Tp>::is_POD_type _PODType;
#if !defined (__BORLANDC__) || (__BORLANDC__ != 0x560)
static _Tp __null_rep();
#else
static _Tp __null_rep;
#endif
enum { use_void_ptr = (sizeof(_UseVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) };
enum { use_const_void_ptr = (sizeof(_UseConstVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) };
enum { use_volatile_void_ptr = (sizeof(_UseVolatileVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) };
enum { use_const_volatile_void_ptr = (sizeof(_UseConstVolatileVoidPtrStorageType(_PODType(), __null_rep())) == sizeof(char*)) };
typedef typename __select<!use_const_volatile_void_ptr,
_Tp,
typename __select<use_void_ptr,
void*,
typename __select<use_const_void_ptr,
const void*,
typename __select<use_volatile_void_ptr,
volatile void*,
const volatile void*>::_Ret >::_Ret >::_Ret >::_Ret _QualifiedType;
#if !defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
/* If the compiler do not support the iterator_traits structure we cannot wrap
* iterators pass to container template methods. The iterator dereferenced value
* has to be storable without any cast in the chosen storage type. To guaranty
* that the void pointer has to be correctly qualified.
*/
typedef _QualifiedType _Type;
#else
/* With iterator_traits we can wrap passed iterators and make the necessary casts.
* We can always use a simple void* storage type:
*/
typedef typename __select<use_const_volatile_void_ptr,
void*,
_Tp>::_Ret _Type;
#endif
};
#endif
template <class _Tp, class _Compare>
struct _AssocStorageTypes {
typedef _StorageType<_Tp> _StorageTypeInfo;
typedef typename _StorageTypeInfo::_Type _SType;
//We need to also check that the comparison functor used to instanciate the assoc container
//is the default Standard less implementation:
enum { ptr_type = _StorageTypeInfo::use_const_volatile_void_ptr };
typedef typename _IsSTLportClass<_Compare>::_Ret _STLportLess;
enum { is_default_less = __type2bool<_STLportLess>::_Ret };
typedef typename __select<is_default_less, _SType, _Tp>::_Ret _KeyStorageType;
typedef typename __select<is_default_less && ptr_type,
_BinaryPredWrapper<_KeyStorageType, _Tp, _Compare>,
_Compare>::_Ret _CompareStorageType;
};
#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
/*
* Base struct to deal with qualifiers
*/
template <class _StorageT, class _QualifiedStorageT>
struct _VoidCastTraitsAux {
typedef _QualifiedStorageT void_cv_type;
typedef _StorageT void_type;
static void_type * uncv_ptr(void_cv_type *__ptr)
{ return __ptr; }
static void_type const* uncv_cptr(void_cv_type const*__ptr)
{ return __ptr; }
static void_type ** uncv_pptr(void_cv_type **__ptr)
{ return __ptr; }
static void_type & uncv_ref(void_cv_type & __ref)
{ return __ref; }
static void_type const& uncv_cref(void_cv_type const& __ref)
{ return __ref; }
static void_cv_type* cv_ptr(void_type *__ptr)
{ return __ptr; }
static void_cv_type const* cv_cptr(void_type const*__ptr)
{ return __ptr; }
static void_cv_type ** cv_pptr(void_type **__ptr)
{ return __ptr; }
static void_cv_type & cv_ref(void_type & __ref)
{ return __ref; }
static void_cv_type const& cv_cref(void_type const& __ref)
{ return __ref; }
};
template <class _VoidCVType>
struct _VoidCastTraitsAuxBase {
typedef _VoidCVType* void_cv_type;
typedef void* void_type;
static void_type* uncv_ptr(void_cv_type *__ptr)
{ return __CONST_CAST(void_type*, __ptr); }
static void_type const* uncv_cptr(void_cv_type const*__ptr)
{ return __CONST_CAST(void_type const*, __ptr); }
static void_type** uncv_pptr(void_cv_type **__ptr)
{ return __CONST_CAST(void_type**, __ptr); }
static void_type& uncv_ref(void_cv_type &__ref)
{ return __CONST_CAST(void_type&, __ref); }
static void_type const& uncv_cref(void_cv_type const& __ptr)
{ return __CONST_CAST(void_type const&, __ptr); }
// The reverse versions
static void_cv_type * cv_ptr(void_type *__ptr)
{ return __CONST_CAST(void_cv_type *, __ptr); }
static void_cv_type const* cv_cptr(void_type const*__ptr)
{ return __CONST_CAST(void_cv_type const*, __ptr); }
static void_cv_type ** cv_pptr(void_type **__ptr)
{ return __CONST_CAST(void_cv_type**, __ptr); }
static void_cv_type & cv_ref(void_type &__ref)
{ return __CONST_CAST(void_cv_type &, __ref); }
static void_cv_type const& cv_cref(void_type const& __ref)
{ return __CONST_CAST(void_cv_type const&, __ref); }
};
_STLP_TEMPLATE_NULL
struct _VoidCastTraitsAux<void*, const void*> : _VoidCastTraitsAuxBase<void const>
{};
_STLP_TEMPLATE_NULL
struct _VoidCastTraitsAux<void*, volatile void*> : _VoidCastTraitsAuxBase<void volatile>
{};
_STLP_TEMPLATE_NULL
struct _VoidCastTraitsAux<void*, const volatile void*> : _VoidCastTraitsAuxBase<void const volatile>
{};
template <class _StorageT, class _ValueT>
struct _CastTraits {
typedef _ValueT value_type;
typedef typename _StorageType<_ValueT>::_QualifiedType _QualifiedStorageT;
typedef _VoidCastTraitsAux<_StorageT, _QualifiedStorageT> cv_traits;
typedef typename cv_traits::void_type void_type;
typedef typename cv_traits::void_cv_type void_cv_type;
static value_type * to_value_type_ptr(void_type *__ptr)
{ return __REINTERPRET_CAST(value_type *, cv_traits::cv_ptr(__ptr)); }
static value_type const* to_value_type_cptr(void_type const*__ptr)
{ return __REINTERPRET_CAST(value_type const*, cv_traits::cv_cptr(__ptr)); }
static value_type ** to_value_type_pptr(void_type **__ptr)
{ return __REINTERPRET_CAST(value_type **, cv_traits::cv_pptr(__ptr)); }
static value_type & to_value_type_ref(void_type &__ref)
{ return __REINTERPRET_CAST(value_type &, cv_traits::cv_ref(__ref)); }
static value_type const& to_value_type_cref(void_type const& __ptr)
{ return __REINTERPRET_CAST(value_type const&, cv_traits::cv_cref(__ptr)); }
// Reverse versions
static void_type * to_storage_type_ptr(value_type *__ptr)
{ return cv_traits::uncv_ptr(__REINTERPRET_CAST(void_cv_type *, __ptr)); }
static void_type const* to_storage_type_cptr(value_type const*__ptr)
{ return cv_traits::uncv_cptr(__REINTERPRET_CAST(void_cv_type const*, __ptr)); }
static void_type ** to_storage_type_pptr(value_type **__ptr)
{ return cv_traits::uncv_pptr(__REINTERPRET_CAST(void_cv_type **, __ptr)); }
static void_type const& to_storage_type_cref(value_type const& __ref)
{ return cv_traits::uncv_cref(__REINTERPRET_CAST(void_cv_type const&, __ref)); }
//Method used to treat set container template method extension
static void_type const& to_storage_type_crefT(value_type const& __ref)
{ return to_storage_type_cref(__ref); }
};
template <class _Tp>
struct _CastTraits<_Tp, _Tp> {
typedef _Tp storage_type;
typedef _Tp value_type;
static value_type * to_value_type_ptr(storage_type *__ptr)
{ return __ptr; }
static value_type const* to_value_type_cptr(storage_type const*__ptr)
{ return __ptr; }
static value_type ** to_value_type_pptr(storage_type **__ptr)
{ return __ptr; }
static value_type & to_value_type_ref(storage_type &__ref)
{ return __ref; }
static value_type const& to_value_type_cref(storage_type const&__ref)
{ return __ref; }
// Reverse versions
static storage_type * to_storage_type_ptr(value_type *__ptr)
{ return __ptr; }
static storage_type const* to_storage_type_cptr(value_type const*__ptr)
{ return __ptr; }
static storage_type ** to_storage_type_pptr(value_type **__ptr)
{ return __ptr; }
static storage_type const& to_storage_type_cref(value_type const& __ref)
{ return __ref; }
//Method used to treat set container template method extension
template <class _Tp1>
static _Tp1 const& to_storage_type_crefT(_Tp1 const& __ref)
{ return __ref; }
};
#define _STLP_USE_ITERATOR_WRAPPER
template <class _StorageT, class _ValueT, class _Iterator>
struct _IteWrapper {
typedef _CastTraits<_StorageT, _ValueT> cast_traits;
typedef iterator_traits<_Iterator> _IteTraits;
typedef typename _IteTraits::iterator_category iterator_category;
typedef _StorageT value_type;
typedef typename _IteTraits::difference_type difference_type;
typedef value_type* pointer;
typedef value_type const& const_reference;
//This wrapper won't be used for input so to avoid surprise
//the reference type will be a const reference:
typedef const_reference reference;
typedef _IteWrapper<_StorageT, _ValueT, _Iterator> _Self;
typedef _Self _Ite;
_IteWrapper(_Iterator &__ite) : _M_ite(__ite) {}
const_reference operator*() const { return cast_traits::to_storage_type_cref(*_M_ite); }
_Self& operator= (_Self const& __rhs) {
_M_ite = __rhs._M_ite;
return *this;
}
_Self& operator++() {
++_M_ite;
return *this;
}
_Self& operator--() {
--_M_ite;
return *this;
}
_Self& operator += (difference_type __offset) {
_M_ite += __offset;
return *this;
}
difference_type operator -(_Self const& __other) const
{ return _M_ite - __other._M_ite; }
bool operator == (_Self const& __other) const
{ return _M_ite == __other._M_ite; }
bool operator != (_Self const& __other) const
{ return _M_ite != __other._M_ite; }
bool operator < (_Self const& __rhs) const
{ return _M_ite < __rhs._M_ite; }
private:
_Iterator _M_ite;
};
template <class _Tp, class _Iterator>
struct _IteWrapper<_Tp, _Tp, _Iterator>
{ typedef _Iterator _Ite; };
#else
/*
* In this config the storage type is qualified in respect of the
* value_type qualification. Simple reinterpret_cast is enough.
*/
template <class _StorageT, class _ValueT>
struct _CastTraits {
typedef _StorageT storage_type;
typedef _ValueT value_type;
static value_type * to_value_type_ptr(storage_type *__ptr)
{ return __REINTERPRET_CAST(value_type*, __ptr); }
static value_type const* to_value_type_cptr(storage_type const*__ptr)
{ return __REINTERPRET_CAST(value_type const*, __ptr); }
static value_type ** to_value_type_pptr(storage_type **__ptr)
{ return __REINTERPRET_CAST(value_type **, __ptr); }
static value_type & to_value_type_ref(storage_type &__ref)
{ return __REINTERPRET_CAST(value_type&, __ref); }
static value_type const& to_value_type_cref(storage_type const&__ref)
{ return __REINTERPRET_CAST(value_type const&, __ref); }
// Reverse versions
static storage_type * to_storage_type_ptr(value_type *__ptr)
{ return __REINTERPRET_CAST(storage_type*, __ptr); }
static storage_type const* to_storage_type_cptr(value_type const*__ptr)
{ return __REINTERPRET_CAST(storage_type const*, __ptr); }
static storage_type ** to_storage_type_pptr(value_type **__ptr)
{ return __REINTERPRET_CAST(storage_type **, __ptr); }
static storage_type const& to_storage_type_cref(value_type const&__ref)
{ return __REINTERPRET_CAST(storage_type const&, __ref); }
template <class _Tp1>
static _Tp1 const& to_storage_type_crefT(_Tp1 const& __ref)
{ return __ref; }
};
#endif
//Wrapper functors:
template <class _StorageT, class _ValueT, class _UnaryPredicate>
struct _UnaryPredWrapper {
typedef _CastTraits<_StorageT, _ValueT> cast_traits;
_UnaryPredWrapper (_UnaryPredicate const& __pred) : _M_pred(__pred) {}
bool operator () (_StorageT const& __ref) const
{ return _M_pred(cast_traits::to_value_type_cref(__ref)); }
private:
_UnaryPredicate _M_pred;
};
template <class _StorageT, class _ValueT, class _BinaryPredicate>
struct _BinaryPredWrapper {
typedef _CastTraits<_StorageT, _ValueT> cast_traits;
_BinaryPredWrapper () {}
_BinaryPredWrapper (_BinaryPredicate const& __pred) : _M_pred(__pred) {}
_BinaryPredicate get_pred() const { return _M_pred; }
bool operator () (_StorageT const& __fst, _StorageT const& __snd) const
{ return _M_pred(cast_traits::to_value_type_cref(__fst), cast_traits::to_value_type_cref(__snd)); }
//Cast operator used to transparently access underlying predicate
//in set::key_comp() method
operator _BinaryPredicate() const
{ return _M_pred; }
private:
_BinaryPredicate _M_pred;
};
_STLP_MOVE_TO_STD_NAMESPACE
_STLP_END_NAMESPACE
#endif /* _STLP_POINTERS_SPEC_TOOLS_H */

View File

@@ -0,0 +1,243 @@
/*
* Copyright (c) 2003
* Francois Dumont
*
* This material is provided "as is", with absolutely no warranty expressed
* or implied. Any use is at your own risk.
*
* Permission to use or copy this software for any purpose is hereby granted
* without fee, provided the above notices are retained on all copies.
* Permission to modify the code and to distribute modified code is granted,
* provided the above notices are retained, and a notice that the code was
* modified is included with the above copyright notice.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef _STLP_SPECIALIZED_VECTOR_H
#define _STLP_SPECIALIZED_VECTOR_H
#ifndef _STLP_POINTERS_SPEC_TOOLS_H
# include <stl/pointers/_tools.h>
#endif
_STLP_BEGIN_NAMESPACE
#define VECTOR_IMPL _STLP_PTR_IMPL_NAME(vector)
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV _Vector_base<void*,allocator<void*> >;
_STLP_EXPORT_TEMPLATE_CLASS _STLP_PRIV VECTOR_IMPL<void*, allocator<void*> >;
#endif
#if defined (_STLP_DEBUG)
# define vector _STLP_NON_DBG_NAME(vector)
_STLP_MOVE_TO_PRIV_NAMESPACE
#endif
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
class vector
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (vector)
: public __stlport_class<vector<_Tp, _Alloc> >
#endif
{
/* In the vector implementation iterators are pointer which give a number
* of opportunities for optimization. To not break those optimizations
* iterators passed to template should not be wrapped for casting purpose.
* So vector implementation will always use a qualified void pointer type and
* won't use iterator wrapping.
*/
typedef _STLP_TYPENAME _STLP_PRIV _StorageType<_Tp>::_QualifiedType _StorageType;
typedef typename _Alloc_traits<_StorageType, _Alloc>::allocator_type _StorageTypeAlloc;
typedef _STLP_PRIV VECTOR_IMPL<_StorageType, _StorageTypeAlloc> _Base;
typedef vector<_Tp, _Alloc> _Self;
typedef _STLP_PRIV _CastTraits<_StorageType, _Tp> cast_traits;
public:
typedef _Tp value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type* iterator;
typedef const value_type* const_iterator;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef random_access_iterator_tag _Iterator_category;
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
_STLP_FORCE_ALLOCATORS(value_type, _Alloc)
typedef typename _Alloc_traits<value_type, _Alloc>::allocator_type allocator_type;
allocator_type get_allocator() const
{ return _STLP_CONVERT_ALLOCATOR(_M_impl.get_allocator(), value_type); }
iterator begin() { return cast_traits::to_value_type_ptr(_M_impl.begin()); }
const_iterator begin() const { return cast_traits::to_value_type_cptr(_M_impl.begin()); }
iterator end() { return cast_traits::to_value_type_ptr(_M_impl.end()); }
const_iterator end() const { return cast_traits::to_value_type_cptr(_M_impl.end()); }
reverse_iterator rbegin() { return reverse_iterator(end()); }
const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
reverse_iterator rend() { return reverse_iterator(begin()); }
const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
size_type size() const { return _M_impl.size(); }
size_type max_size() const { return _M_impl.max_size(); }
size_type capacity() const { return _M_impl.capacity(); }
bool empty() const { return _M_impl.empty(); }
reference operator[](size_type __n) { return cast_traits::to_value_type_ref(_M_impl[__n]); }
const_reference operator[](size_type __n) const { return cast_traits::to_value_type_cref(_M_impl[__n]); }
reference front() { return cast_traits::to_value_type_ref(_M_impl.front()); }
const_reference front() const { return cast_traits::to_value_type_cref(_M_impl.front()); }
reference back() { return cast_traits::to_value_type_ref(_M_impl.back()); }
const_reference back() const { return cast_traits::to_value_type_cref(_M_impl.back()); }
reference at(size_type __n) { return cast_traits::to_value_type_ref(_M_impl.at(__n)); }
const_reference at(size_type __n) const { return cast_traits::to_value_type_cref(_M_impl.at(__n)); }
explicit vector(const allocator_type& __a = allocator_type())
: _M_impl(_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit vector(size_type __n, const value_type& __val = _STLP_DEFAULT_CONSTRUCTED(value_type),
#else
vector(size_type __n, const value_type& __val,
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
const allocator_type& __a = allocator_type())
: _M_impl(__n, cast_traits::to_storage_type_cref(__val),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
explicit vector(size_type __n)
: _M_impl(__n, allocator_type() ) {}
#endif
vector(const _Self& __x)
: _M_impl(__x._M_impl) {}
#if !defined (_STLP_NO_MOVE_SEMANTIC)
explicit vector(__move_source<_Self> src)
: _M_impl(__move_source<_Base>(src.get()._M_impl)) {}
#endif
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL )
: _M_impl(__first, __last,
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
template <class _InputIterator>
vector(_InputIterator __first, _InputIterator __last)
: _M_impl(__first, __last) {}
# endif
#else
vector(const_iterator __first, const_iterator __last,
const allocator_type& __a = allocator_type())
: _M_impl(cast_traits::to_storage_type_cptr(__first), cast_traits::to_storage_type_cptr(__last),
_STLP_CONVERT_ALLOCATOR(__a, _StorageType)) {}
#endif /* _STLP_MEMBER_TEMPLATES */
_Self& operator=(const _Self& __x) { _M_impl = __x._M_impl; return *this; }
void reserve(size_type __n) {_M_impl.reserve(__n);}
void assign(size_type __n, const value_type& __val)
{ _M_impl.assign(__n, cast_traits::to_storage_type_cref(__val)); }
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
void assign(_InputIterator __first, _InputIterator __last)
{ _M_impl.assign(__first, __last); }
#else
void assign(const_iterator __first, const_iterator __last) {
_M_impl.assign(cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
#endif /* _STLP_MEMBER_TEMPLATES */
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
void push_back(const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void push_back(const value_type& __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ _M_impl.push_back(cast_traits::to_storage_type_cref(__x)); }
#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
iterator insert(iterator __pos, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
iterator insert(iterator __pos, const value_type& __x)
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
{ return cast_traits::to_value_type_ptr(_M_impl.insert(cast_traits::to_storage_type_ptr(__pos),
cast_traits::to_storage_type_cref(__x))); }
#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
void push_back() { _M_impl.push_back(); }
iterator insert(iterator __pos)
{ return _M_impl.insert(cast_traits::to_storage_type_ptr(__pos)); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
void swap(_Self& __x) { _M_impl.swap(__x._M_impl); }
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
void _M_swap_workaround(_Self& __x) { swap(__x); }
#endif
#if defined (_STLP_MEMBER_TEMPLATES)
template <class _InputIterator>
void insert(iterator __pos, _InputIterator __first, _InputIterator __last)
{ _M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __first, __last); }
#else
void insert(iterator __pos, const_iterator __first, const_iterator __last) {
_M_impl.insert(cast_traits::to_storage_type_ptr(__pos), cast_traits::to_storage_type_cptr(__first),
cast_traits::to_storage_type_cptr(__last));
}
#endif
void insert (iterator __pos, size_type __n, const value_type& __x) {
_M_impl.insert(cast_traits::to_storage_type_ptr(__pos), __n, cast_traits::to_storage_type_cref(__x));
}
void pop_back() {_M_impl.pop_back();}
iterator erase(iterator __pos)
{return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__pos)));}
iterator erase(iterator __first, iterator __last) {
return cast_traits::to_value_type_ptr(_M_impl.erase(cast_traits::to_storage_type_ptr(__first),
cast_traits::to_storage_type_ptr(__last)));
}
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size, const value_type& __x = _STLP_DEFAULT_CONSTRUCTED(value_type))
#else
void resize(size_type __new_size, const value_type& __x)
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
{ _M_impl.resize(__new_size, cast_traits::to_storage_type_cref(__x)); }
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
void resize(size_type __new_size) { _M_impl.resize(__new_size); }
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
void clear() { _M_impl.clear(); }
private:
_Base _M_impl;
};
#if defined (vector)
# undef vector
_STLP_MOVE_TO_STD_NAMESPACE
#endif
#undef VECTOR_IMPL
_STLP_END_NAMESPACE
#endif /* _STLP_SPECIALIZED_VECTOR_H */