first commit
This commit is contained in:
628
extern/STLport/5.2.1/stlport/stl/debug/_debug.c
vendored
Normal file
628
extern/STLport/5.2.1/stlport/stl/debug/_debug.c
vendored
Normal file
@@ -0,0 +1,628 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DEBUG_C
|
||||
#define _STLP_DEBUG_C
|
||||
|
||||
#if defined (_STLP_DEBUG)
|
||||
#if defined (_STLP_THREADS)
|
||||
# if !defined (_STLP_NEED_MUTABLE)
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock) _Lock._M_acquire_lock();
|
||||
# define _STLP_RELEASE_LOCK(_Lock) _Lock._M_release_lock();
|
||||
# else
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_acquire_lock();
|
||||
# define _STLP_RELEASE_LOCK(_Lock) ((_STLP_mutex&)_Lock)._M_release_lock();
|
||||
# endif /* _STLP_NEED_MUTABLE */
|
||||
#else
|
||||
# define _STLP_ACQUIRE_LOCK(_Lock)
|
||||
# define _STLP_RELEASE_LOCK(_Lock)
|
||||
#endif /* _STLP_THREADS */
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
//==========================================================
|
||||
// global non-inline functions
|
||||
//==========================================================
|
||||
// [ i1, i2)
|
||||
#if !defined (__DMC__)
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL
|
||||
stlp_in_range_aux(const _Iterator& __it, const _Iterator& __first,
|
||||
const _Iterator& __last, const random_access_iterator_tag &) {
|
||||
return ( __it >= __first &&
|
||||
__it < __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Iterator1, class _Iterator>
|
||||
#if defined (_STLP_MSVC)
|
||||
inline bool _STLP_CALL stlp_in_range_aux(_Iterator1 __it, const _Iterator& __first,
|
||||
#else
|
||||
inline bool _STLP_CALL stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first,
|
||||
#endif
|
||||
const _Iterator& __last, const forward_iterator_tag &) {
|
||||
_Iterator1 __i(__first);
|
||||
for (; __i != __last && __i != __it; ++__i);
|
||||
return (__i != __last);
|
||||
}
|
||||
|
||||
#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
|
||||
template <class _Iterator1, class _Iterator>
|
||||
inline bool _STLP_CALL
|
||||
stlp_in_range_aux(const _Iterator1& __it, const _Iterator& __first,
|
||||
const _Iterator& __last, const bidirectional_iterator_tag &) {
|
||||
_Iterator1 __i(__first);
|
||||
for (; __i != __last && __i != __it; ++__i);
|
||||
return (__i != __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range_aux(const _Iterator& __first, const _Iterator& __last,
|
||||
const __false_type& /*_IsIntegral*/) {
|
||||
_STLP_VERBOSE_RETURN(__valid_range(__first,__last), _StlMsg_INVALID_RANGE )
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Integral>
|
||||
bool _STLP_CALL __check_range_aux(_Integral /*__first*/, _Integral /*__last*/,
|
||||
const __true_type& /*_IsIntegral*/)
|
||||
{ return true; }
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last) {
|
||||
typedef typename _IsIntegral<_Iterator>::_Ret _Integral;
|
||||
return __check_range_aux(__first, __last, _Integral());
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __it,
|
||||
const _Iterator& __start, const _Iterator& __finish) {
|
||||
_STLP_VERBOSE_RETURN(stlp_in_range(__it, __start, __finish),
|
||||
_StlMsg_NOT_IN_RANGE_1)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator& __first, const _Iterator& __last,
|
||||
const _Iterator& __start, const _Iterator& __finish) {
|
||||
_STLP_VERBOSE_RETURN(stlp_in_range(__first, __last, __start, __finish),
|
||||
_StlMsg_NOT_IN_RANGE_2)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Tp>
|
||||
bool _STLP_CALL __check_ptr_range(const _Tp* __first, const _Tp* __last) {
|
||||
_STLP_VERBOSE_RETURN((__first != 0 || __last == 0), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_RETURN(__valid_range(__first, __last, random_access_iterator_tag()),
|
||||
_StlMsg_INVALID_RANGE)
|
||||
return true;
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_range(const __owned_list* __base,
|
||||
const _Iterator& __first,
|
||||
const _Iterator& __last) {
|
||||
typedef __owned_link _L_type;
|
||||
_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
_L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node);
|
||||
_L_type* __pos = __prev->_M_next;
|
||||
|
||||
while (__pos != 0) {
|
||||
if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) &&
|
||||
stlp_in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator,
|
||||
__first._M_iterator, __last._M_iterator,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
|
||||
__pos->_M_owner = 0;
|
||||
__prev->_M_next = __pos->_M_next;
|
||||
}
|
||||
else {
|
||||
__prev = __pos;
|
||||
}
|
||||
__pos = __prev->_M_next;
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
|
||||
const _Iterator& __it) {
|
||||
typedef __owned_link _L_type;
|
||||
_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
_L_type* __prev = __CONST_CAST(_L_type*, &__base->_M_node);
|
||||
_L_type* __pos = __prev->_M_next;
|
||||
while (__pos != 0) {
|
||||
// this requires safe iterators to be derived from __owned_link
|
||||
if ((__pos != __STATIC_CAST(const _L_type*, &__it)) &&
|
||||
(__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) {
|
||||
__pos->_M_owner = 0;
|
||||
__prev->_M_next = __pos->_M_next;
|
||||
}
|
||||
else {
|
||||
__prev = __pos;
|
||||
}
|
||||
__pos = __prev->_M_next;
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __change_range_owner(const _Iterator& __first,
|
||||
const _Iterator& __last,
|
||||
const __owned_list* __dst) {
|
||||
if (__first._Owner() == __dst)
|
||||
return;
|
||||
|
||||
typedef __owned_link _L_type;
|
||||
// Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
|
||||
//_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
__owned_list *__base = __CONST_CAST(__owned_list*, __first._Owner());
|
||||
_L_type* __src_prev = &__base->_M_node;
|
||||
_L_type* __pos = __src_prev->_M_next;
|
||||
_L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node);
|
||||
|
||||
while (__pos != 0) {
|
||||
if (!(&__first == __STATIC_CAST(_Iterator*, __pos) || &__last == __STATIC_CAST(_Iterator*, __pos)) &&
|
||||
stlp_in_range_aux(__STATIC_CAST(_Iterator*, __pos)->_M_iterator,
|
||||
__first._M_iterator, __last._M_iterator,
|
||||
_STLP_ITERATOR_CATEGORY(__first, _Iterator))) {
|
||||
__pos->_M_owner = __CONST_CAST(__owned_list*, __dst);
|
||||
//remove __pos from __base:
|
||||
__src_prev->_M_next = __pos->_M_next;
|
||||
//add __pos to __dst:
|
||||
__pos->_M_next = __dst_prev->_M_next;
|
||||
__dst_prev->_M_next = __pos;
|
||||
}
|
||||
else {
|
||||
__src_prev = __pos;
|
||||
}
|
||||
__pos = __src_prev->_M_next;
|
||||
}
|
||||
|
||||
#if defined(_STLP_WCE) && defined(_ARM_)
|
||||
// Note: This part is needed for compiling under Windows CE under ARM and correctly using
|
||||
// _STLP_DEBUG mode. This comes from a bug in the ARM compiler where checked iterators that
|
||||
// are passed by value are not copied over correctly. When __change_range_owner is called,
|
||||
// e.g. in std::list::splice() the wrong _M_owner field gets modified and the __first
|
||||
// iterator has the old _M_owner field, but was moved to the new __owned_list. Setting
|
||||
// the first iterator's _M_owner field fixes this. Ugly but works.
|
||||
__pos = __CONST_CAST(_Iterator*, &__first);
|
||||
__pos->_M_owner = __CONST_CAST(__owned_list*, __dst);
|
||||
#endif
|
||||
//_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __change_ite_owner(const _Iterator& __it,
|
||||
const __owned_list* __dst) {
|
||||
if (__it._Owner() == __dst)
|
||||
return;
|
||||
|
||||
typedef __owned_link _L_type;
|
||||
// Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
|
||||
//_STLP_ACQUIRE_LOCK(__base->_M_lock)
|
||||
__owned_list *__base = __CONST_CAST(__owned_list*, __it._Owner());
|
||||
_L_type* __prev = &__base->_M_node;
|
||||
_L_type* __pos = __prev->_M_next;
|
||||
_L_type* __dst_prev = __CONST_CAST(_L_type*, &__dst->_M_node);
|
||||
|
||||
while (__pos != 0) {
|
||||
// this requires safe iterators to be derived from __owned_link
|
||||
if ((__pos != __STATIC_CAST(const _L_type*, &__it)) &&
|
||||
(__STATIC_CAST(_Iterator*, __pos)->_M_iterator == __it._M_iterator)) {
|
||||
__pos->_M_owner = __CONST_CAST(__owned_list*, __dst);
|
||||
//remove __pos from __base:
|
||||
__prev->_M_next = __pos->_M_next;
|
||||
//add __pos to __dst:
|
||||
__pos->_M_next = __dst_prev->_M_next;
|
||||
__dst_prev->_M_next = __pos;
|
||||
}
|
||||
else {
|
||||
__prev = __pos;
|
||||
}
|
||||
__pos = __prev->_M_next;
|
||||
}
|
||||
//_STLP_RELEASE_LOCK(__base->_M_lock)
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_DEBUG */
|
||||
|
||||
#if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
|
||||
|
||||
# ifndef _STLP_INTERNAL_CSTDLIB
|
||||
# include <stl/_cstdlib.h>
|
||||
# endif
|
||||
|
||||
//==========================================================
|
||||
// .c section
|
||||
// owned_list non-inline methods and global functions
|
||||
//==========================================================
|
||||
|
||||
# if defined (_STLP_ASSERTIONS)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
# if !defined (_STLP_STRING_LITERAL)
|
||||
# define _STLP_STRING_LITERAL(__x) __x
|
||||
# endif
|
||||
|
||||
# if defined (_STLP_USE_WIDE_INTERFACE)
|
||||
// note: WinCE needs this to format single-byte strings in __stl_debug_engine::_Message
|
||||
# define _STLP_PERCENT_S "%hs"
|
||||
# else
|
||||
# define _STLP_PERCENT_S "%s"
|
||||
# endif /* _STLP_USE_WIDE_INTERFACE */
|
||||
|
||||
# define _STLP_MESSAGE_TABLE_BODY = { \
|
||||
_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error: " _STLP_PERCENT_S "\n"), \
|
||||
_STLP_STRING_LITERAL(_STLP_PERCENT_S "(%d): STL assertion failure : " _STLP_PERCENT_S "\n" _STLP_ASSERT_MSG_TRAILER), \
|
||||
_STLP_STRING_LITERAL("\n" _STLP_PERCENT_S "(%d): STL error : " _STLP_PERCENT_S "\n" _STLP_PERCENT_S "(%d): STL assertion failure: " _STLP_PERCENT_S " \n" _STLP_ASSERT_MSG_TRAILER), \
|
||||
_STLP_STRING_LITERAL("Invalid argument to operation (see operation documentation)"), \
|
||||
_STLP_STRING_LITERAL("Taking an iterator out of destroyed (or otherwise corrupted) container"), \
|
||||
_STLP_STRING_LITERAL("Trying to extract an object out from empty container"),\
|
||||
_STLP_STRING_LITERAL("Past-the-end iterator could not be erased"), \
|
||||
_STLP_STRING_LITERAL("Index out of bounds"), \
|
||||
_STLP_STRING_LITERAL("Container doesn't own the iterator"), \
|
||||
_STLP_STRING_LITERAL("Container is owner of the iterator, but should not"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) iterator used"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) lefthand iterator in expression"), \
|
||||
_STLP_STRING_LITERAL("Uninitialized or invalidated (by mutating operation) righthand iterator in expression"), \
|
||||
_STLP_STRING_LITERAL("Iterators used in expression are from different owners"), \
|
||||
_STLP_STRING_LITERAL("Iterator could not be dereferenced (past-the-end ?)"), \
|
||||
_STLP_STRING_LITERAL("Range [first,last) is invalid"), \
|
||||
_STLP_STRING_LITERAL("Iterator is not in range [first,last)"), \
|
||||
_STLP_STRING_LITERAL("Range [first,last) is not in range [start,finish)"), \
|
||||
_STLP_STRING_LITERAL("The advance would produce invalid iterator"), \
|
||||
_STLP_STRING_LITERAL("Iterator is singular (advanced beyond the bounds ?)"), \
|
||||
_STLP_STRING_LITERAL("Invalid strict weak ordering predicate, if pred(a, b) then we should have !pred(b, a)"), \
|
||||
_STLP_STRING_LITERAL("Invalid equivalent predicate, if pred(a, b) then we should have pred(b, a)"), \
|
||||
_STLP_STRING_LITERAL("Memory block deallocated twice"), \
|
||||
_STLP_STRING_LITERAL("Deallocating a block that was never allocated"), \
|
||||
_STLP_STRING_LITERAL("Deallocating a memory block allocated for another type"), \
|
||||
_STLP_STRING_LITERAL("Size of block passed to deallocate() doesn't match block size"), \
|
||||
_STLP_STRING_LITERAL("Pointer underrun - safety margin at front of memory block overwritten"), \
|
||||
_STLP_STRING_LITERAL("Pointer overrrun - safety margin at back of memory block overwritten"), \
|
||||
_STLP_STRING_LITERAL("Attempt to dereference null pointer returned by auto_ptr::get()"), \
|
||||
_STLP_STRING_LITERAL("Memory allocation function returned a wrongly align memory block"), \
|
||||
_STLP_STRING_LITERAL("Unknown problem") \
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
const char* __stl_debug_engine<_Dummy>::_Message_table[_StlMsg_MAX] _STLP_MESSAGE_TABLE_BODY;
|
||||
|
||||
# undef _STLP_STRING_LITERAL
|
||||
# undef _STLP_PERCENT_S
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# if !defined (_STLP_DEBUG_MESSAGE)
|
||||
# ifndef _STLP_INTERNAL_CSTDARG
|
||||
# include <stl/_cstdarg.h>
|
||||
# endif
|
||||
# ifndef _STLP_INTERNAL_CSTDIO
|
||||
# include <stl/_cstdio.h>
|
||||
# endif
|
||||
# if defined (_STLP_DEBUG_MODE_THROWS) && !defined (_STLP_RANGE_ERRORS_H)
|
||||
# include <stl/_range_errors.h>
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...) {
|
||||
STLPORT_CSTD::va_list __args;
|
||||
va_start( __args, __format_str );
|
||||
|
||||
# if !defined (_STLP_DEBUG_MODE_THROWS)
|
||||
# if defined (_STLP_USE_WIDE_INTERFACE)
|
||||
TCHAR __buffer[512];
|
||||
int _convert = strlen(__format_str) + 1;
|
||||
LPWSTR _lpw = (LPWSTR)alloca(_convert * sizeof(wchar_t));
|
||||
_lpw[0] = '\0';
|
||||
MultiByteToWideChar(GetACP(), 0, __format_str, -1, _lpw, _convert);
|
||||
wvsprintf(__buffer, _lpw, __args);
|
||||
_STLP_WINCE_TRACE(__buffer);
|
||||
# elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL))
|
||||
char __buffer [4096];
|
||||
|
||||
# if !defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
|
||||
vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args);
|
||||
# else
|
||||
vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args);
|
||||
# endif
|
||||
|
||||
OutputDebugStringA(__buffer);
|
||||
|
||||
# elif defined (__amigaos__)
|
||||
STLPORT_CSTD::vfprintf(stderr, __format_str, (char *)__args);
|
||||
# else
|
||||
STLPORT_CSTD::vfprintf(stderr, __format_str, __args);
|
||||
# endif
|
||||
# else
|
||||
char __buffer[4096];
|
||||
|
||||
# if defined (_STLP_USE_SAFE_STRING_FUNCTIONS)
|
||||
vsnprintf_s(__buffer, _STLP_ARRAY_SIZE(__buffer), _TRUNCATE, __format_str, __args);
|
||||
# elif defined (_STLP_WIN32) && (defined(_STLP_MSVC) || defined (__ICL))
|
||||
vsnprintf(__buffer, _STLP_ARRAY_SIZE(__buffer), __format_str, __args);
|
||||
# else
|
||||
vsprintf(__buffer, __format_str, __args);
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef _STLP_DEBUG_MESSAGE_POST
|
||||
_STLP_DEBUG_MESSAGE_POST
|
||||
# endif
|
||||
|
||||
va_end(__args);
|
||||
|
||||
# if defined (_STLP_DEBUG_MODE_THROWS)
|
||||
__stl_throw_runtime_error(__buffer);
|
||||
# endif
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# else
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Message(const char * __format_str, ...)
|
||||
{}
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
# endif /* _STLP_DEBUG_MESSAGE */
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_IndexedError(int __error_ind, const char* __f, int __l) {
|
||||
__stl_debug_message(_Message_table[_StlFormat_ERROR_RETURN],
|
||||
__f, __l, _Message_table[__error_ind]);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l) {
|
||||
__stl_debug_message(_Message_table[_StlFormat_VERBOSE_ASSERTION_FAILURE],
|
||||
__f, __l, _Message_table[__error_ind], __f, __l, __expr);
|
||||
__stl_debug_terminate();
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Assert(const char* __expr, const char* __f, int __l) {
|
||||
__stl_debug_message(_Message_table[_StlFormat_ASSERTION_FAILURE],__f, __l, __expr);
|
||||
__stl_debug_terminate();
|
||||
}
|
||||
|
||||
// if exceptions are present, sends unique exception
|
||||
// if not, calls abort() to terminate
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Terminate()
|
||||
{ _STLP_ABORT(); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_ASSERTIONS */
|
||||
|
||||
# if defined (_STLP_DEBUG)
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
//==========================================================
|
||||
// owned_list non-inline methods
|
||||
//==========================================================
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Invalidate_all(__owned_list* __l) {
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock);
|
||||
_Stamp_all(__l, 0);
|
||||
__l->_M_node._M_next =0;
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock);
|
||||
}
|
||||
|
||||
// boris : this is unasafe routine; should be used from within critical section only !
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Stamp_all(__owned_list* __l, __owned_list* __o) {
|
||||
// crucial
|
||||
if (__l->_M_node._M_owner) {
|
||||
for (__owned_link* __pos = (__owned_link*)__l->_M_node._M_next;
|
||||
__pos != 0; __pos = (__owned_link*)__pos->_M_next) {
|
||||
_STLP_ASSERT(__pos->_Owner()== __l)
|
||||
__pos->_M_owner=__o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Verify(const __owned_list* __l) {
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock);
|
||||
if (__l) {
|
||||
_STLP_ASSERT(__l->_M_node._Owner() != 0)
|
||||
for (__owned_link* __pos = (__owned_link*)__l->_M_node._M_next;
|
||||
__pos != 0; __pos = (__owned_link*)__pos->_M_next) {
|
||||
_STLP_ASSERT(__pos->_Owner()== __l)
|
||||
}
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock);
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Swap_owners(__owned_list& __x, __owned_list& __y) {
|
||||
/*
|
||||
* according to the standard : --no swap() function invalidates any references,
|
||||
* pointers, or iterators referring to the elements of the containers being swapped.
|
||||
*/
|
||||
|
||||
__owned_link* __tmp;
|
||||
|
||||
/*
|
||||
* boris : there is a deadlock potential situation here if we lock two containers sequentially.
|
||||
* As user is supposed to provide its own synchronization around swap() ( it is unsafe to do any container/iterator access
|
||||
* in parallel with swap()), we just do not use any locking at all -- that behaviour is closer to non-debug version
|
||||
*/
|
||||
|
||||
__tmp = __x._M_node._M_next;
|
||||
|
||||
_Stamp_all(&__x, &__y);
|
||||
_Stamp_all(&__y, &__x);
|
||||
|
||||
__x._M_node._M_next = __y._M_node._M_next;
|
||||
__y._M_node._M_next = __tmp;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Set_owner(__owned_list& __src, __owned_list& __dst) {
|
||||
if (&__src == &__dst)
|
||||
return;
|
||||
|
||||
// Check __stl_debug_engine<_Dummy>::_Swap_owners comments to see why there is no lock here
|
||||
typedef __owned_link _L_type;
|
||||
_L_type* __prev = &__src._M_node;
|
||||
_L_type* __pos = __prev->_M_next;
|
||||
|
||||
while (__pos != 0) {
|
||||
__pos->_M_owner = &__dst;
|
||||
__prev = __pos;
|
||||
__pos = __prev->_M_next;
|
||||
}
|
||||
__prev->_M_next = __dst._M_node._M_next;
|
||||
__dst._M_node._M_next = __src._M_node._M_next;
|
||||
__src._M_node._M_next = 0;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_M_detach(__owned_list* __l, __owned_link* __c_node) {
|
||||
if (__l != 0) {
|
||||
|
||||
_STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
|
||||
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock)
|
||||
// boris : re-test the condition in case someone else already deleted us
|
||||
if(__c_node->_M_owner != 0) {
|
||||
__owned_link* __prev, *__next;
|
||||
|
||||
for (__prev = &__l->_M_node; (__next = __prev->_M_next) != __c_node;
|
||||
__prev = __next) {
|
||||
_STLP_ASSERT(__next && __next->_Owner() == __l)
|
||||
}
|
||||
|
||||
__prev->_M_next = __c_node->_M_next;
|
||||
__c_node->_M_owner=0;
|
||||
}
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock)
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_M_attach(__owned_list* __l, __owned_link* __c_node) {
|
||||
if (__l ==0) {
|
||||
(__c_node)->_M_owner = 0;
|
||||
} else {
|
||||
_STLP_VERBOSE_ASSERT(__l->_Owner()!=0, _StlMsg_INVALID_CONTAINER)
|
||||
_STLP_ACQUIRE_LOCK(__l->_M_lock)
|
||||
__c_node->_M_owner = __l;
|
||||
__c_node->_M_next = __l->_M_node._M_next;
|
||||
__l->_M_node._M_next = __c_node;
|
||||
_STLP_RELEASE_LOCK(__l->_M_lock)
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
void* _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Get_container_ptr(const __owned_link* __l) {
|
||||
const __owned_list* __owner = __l->_Owner();
|
||||
_STLP_VERBOSE_RETURN_0(__owner != 0, _StlMsg_INVALID_ITERATOR)
|
||||
void* __ret = __CONST_CAST(void*,__owner->_Owner());
|
||||
_STLP_VERBOSE_RETURN_0(__ret !=0, _StlMsg_INVALID_CONTAINER)
|
||||
return __ret;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_same_owner(const __owned_link& __i1,
|
||||
const __owned_link& __i2) {
|
||||
_STLP_VERBOSE_RETURN(__i1._Valid(), _StlMsg_INVALID_LEFTHAND_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN(__i2._Valid(), _StlMsg_INVALID_RIGHTHAND_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN((__i1._Owner() == __i2._Owner()), _StlMsg_DIFFERENT_OWNERS)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_same_or_null_owner(const __owned_link& __i1,
|
||||
const __owned_link& __i2) {
|
||||
_STLP_VERBOSE_RETURN(__i1._Owner() == __i2._Owner(), _StlMsg_DIFFERENT_OWNERS)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_if_owner( const __owned_list * __l, const __owned_link& __it) {
|
||||
const __owned_list* __owner_ptr = __it._Owner();
|
||||
_STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN(__l == __owner_ptr, _StlMsg_NOT_OWNER)
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Dummy>
|
||||
bool _STLP_CALL
|
||||
__stl_debug_engine<_Dummy>::_Check_if_not_owner( const __owned_list * __l, const __owned_link& __it) {
|
||||
const __owned_list* __owner_ptr = __it._Owner();
|
||||
_STLP_VERBOSE_RETURN(__owner_ptr != 0, _StlMsg_INVALID_ITERATOR)
|
||||
_STLP_VERBOSE_RETURN(__l != __owner_ptr, _StlMsg_SHOULD_NOT_OWNER)
|
||||
return true;
|
||||
}
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# endif /* _STLP_DEBUG */
|
||||
|
||||
#endif /* if defined (EXPOSE_GLOBALS_IMPLEMENTATION) */
|
||||
|
||||
#endif /* header guard */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
473
extern/STLport/5.2.1/stlport/stl/debug/_debug.h
vendored
Normal file
473
extern/STLport/5.2.1/stlport/stl/debug/_debug.h
vendored
Normal file
@@ -0,0 +1,473 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DEBUG_H
|
||||
#define _STLP_DEBUG_H
|
||||
|
||||
#if (defined (_STLP_DEBUG) || defined (_STLP_DEBUG_ALLOC)) && \
|
||||
!defined (_STLP_ASSERTIONS)
|
||||
# define _STLP_ASSERTIONS 1
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_ASSERTIONS)
|
||||
|
||||
# if !defined (_STLP_FILE__)
|
||||
# define _STLP_FILE__ __FILE__
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
enum {
|
||||
//General errors
|
||||
_StlFormat_ERROR_RETURN,
|
||||
_StlFormat_ASSERTION_FAILURE,
|
||||
_StlFormat_VERBOSE_ASSERTION_FAILURE,
|
||||
_StlMsg_INVALID_ARGUMENT,
|
||||
//Container/Iterator related errors
|
||||
_StlMsg_INVALID_CONTAINER,
|
||||
_StlMsg_EMPTY_CONTAINER,
|
||||
_StlMsg_ERASE_PAST_THE_END,
|
||||
_StlMsg_OUT_OF_BOUNDS,
|
||||
_StlMsg_NOT_OWNER,
|
||||
_StlMsg_SHOULD_NOT_OWNER,
|
||||
_StlMsg_INVALID_ITERATOR,
|
||||
_StlMsg_INVALID_LEFTHAND_ITERATOR,
|
||||
_StlMsg_INVALID_RIGHTHAND_ITERATOR,
|
||||
_StlMsg_DIFFERENT_OWNERS ,
|
||||
_StlMsg_NOT_DEREFERENCEABLE ,
|
||||
_StlMsg_INVALID_RANGE ,
|
||||
_StlMsg_NOT_IN_RANGE_1 ,
|
||||
_StlMsg_NOT_IN_RANGE_2 ,
|
||||
_StlMsg_INVALID_ADVANCE ,
|
||||
_StlMsg_SINGULAR_ITERATOR ,
|
||||
//Bad predicate for sorting
|
||||
_StlMsg_INVALID_STRICT_WEAK_PREDICATE,
|
||||
_StlMsg_INVALID_EQUIVALENT_PREDICATE,
|
||||
// debug alloc messages
|
||||
_StlMsg_DBA_DELETED_TWICE ,
|
||||
_StlMsg_DBA_NEVER_ALLOCATED ,
|
||||
_StlMsg_DBA_TYPE_MISMATCH ,
|
||||
_StlMsg_DBA_SIZE_MISMATCH ,
|
||||
_StlMsg_DBA_UNDERRUN ,
|
||||
_StlMsg_DBA_OVERRUN ,
|
||||
// auto_ptr messages
|
||||
_StlMsg_AUTO_PTR_NULL ,
|
||||
//Memory alignent message
|
||||
_StlMsg_WRONG_MEMORY_ALIGNMENT,
|
||||
_StlMsg_UNKNOWN
|
||||
/* _StlMsg_MAX */
|
||||
};
|
||||
|
||||
/* have to hardcode that ;() */
|
||||
# define _StlMsg_MAX 31
|
||||
|
||||
class __owned_link;
|
||||
class __owned_list;
|
||||
|
||||
# if defined (_STLP_DEBUG_MODE_THROWS)
|
||||
# define _STLP_MESSAGE_NORETURN _STLP_FUNCTION_THROWS
|
||||
# else
|
||||
# define _STLP_MESSAGE_NORETURN
|
||||
# endif
|
||||
|
||||
template <class _Dummy>
|
||||
class __stl_debug_engine {
|
||||
public:
|
||||
// Basic routine to report any debug message
|
||||
// Use _STLP_DEBUG_MESSAGE to override
|
||||
static void _STLP_MESSAGE_NORETURN _STLP_CALL _Message(const char * format_str, ...);
|
||||
|
||||
// Micsellanous function to report indexed error message
|
||||
static void _STLP_CALL _IndexedError(int __ind, const char* __f, int __l);
|
||||
|
||||
// Basic assertion report mechanism.
|
||||
// Reports failed assertion via __stl_debug_message and calls _Terminate
|
||||
// if _STLP_DEBUG_TERMINATE is specified, calls __stl_debug_terminate instead
|
||||
static void _STLP_CALL _Assert(const char* __expr, const char* __f, int __l);
|
||||
|
||||
// The same, with additional diagnostics
|
||||
static void _STLP_CALL _VerboseAssert(const char* __expr, int __error_ind, const char* __f, int __l);
|
||||
|
||||
// If exceptions are present, sends unique exception
|
||||
// If not, calls _STLP_ABORT() to terminate
|
||||
// Use _STLP_DEBUG_TERMINATE to override
|
||||
static void _STLP_CALL _Terminate();
|
||||
|
||||
# if defined (_STLP_DEBUG)
|
||||
// owned_list/link delegate non-inline functions here
|
||||
|
||||
static bool _STLP_CALL _Check_same_owner( const __owned_link& __i1,
|
||||
const __owned_link& __i2);
|
||||
static bool _STLP_CALL _Check_same_or_null_owner( const __owned_link& __i1,
|
||||
const __owned_link& __i2);
|
||||
static bool _STLP_CALL _Check_if_owner( const __owned_list*, const __owned_link&);
|
||||
|
||||
static bool _STLP_CALL _Check_if_not_owner( const __owned_list*, const __owned_link&);
|
||||
|
||||
static void _STLP_CALL _Verify(const __owned_list*);
|
||||
|
||||
static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list&);
|
||||
|
||||
static void _STLP_CALL _Invalidate_all(__owned_list*);
|
||||
|
||||
static void _STLP_CALL _Set_owner(__owned_list& /*src*/, __owned_list& /*dst*/);
|
||||
|
||||
static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*);
|
||||
|
||||
static void _STLP_CALL _M_detach(__owned_list*, __owned_link*);
|
||||
|
||||
static void _STLP_CALL _M_attach(__owned_list*, __owned_link*);
|
||||
|
||||
// accessor : check and get pointer to the container
|
||||
static void* _STLP_CALL _Get_container_ptr(const __owned_link*);
|
||||
# endif
|
||||
|
||||
// debug messages and formats
|
||||
static const char* _Message_table[_StlMsg_MAX];
|
||||
};
|
||||
|
||||
# undef _STLP_MESSAGE_NORETURN
|
||||
|
||||
# if defined (_STLP_USE_TEMPLATE_EXPORT)
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __stl_debug_engine<bool>;
|
||||
# endif
|
||||
|
||||
typedef __stl_debug_engine<bool> __stl_debugger;
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
# if !defined (_STLP_ASSERT)
|
||||
# define _STLP_ASSERT(expr) \
|
||||
if (!(expr)) { _STLP_PRIV __stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__); }
|
||||
# endif
|
||||
|
||||
#else
|
||||
# define _STLP_ASSERT(expr)
|
||||
#endif
|
||||
|
||||
// this section is for _STLP_DEBUG only
|
||||
#if defined (_STLP_DEBUG)
|
||||
|
||||
# if !defined (_STLP_VERBOSE_ASSERT)
|
||||
// fbp : new form not requiring ";"
|
||||
# define _STLP_VERBOSE_ASSERT(expr, __diag_num) \
|
||||
if (!(expr)) { _STLP_PRIV __stl_debugger::_VerboseAssert\
|
||||
( # expr, _STLP_PRIV __diag_num, _STLP_FILE__, __LINE__ ); \
|
||||
}
|
||||
# endif
|
||||
|
||||
# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr)
|
||||
|
||||
# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
# define _STLP_STD_DEBUG_CHECK(expr) _STLP_DEBUG_CHECK(expr)
|
||||
# else
|
||||
# define _STLP_STD_DEBUG_CHECK(expr)
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_VERBOSE_RETURN)
|
||||
# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \
|
||||
_STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__ , __LINE__); \
|
||||
return false; }
|
||||
# endif
|
||||
|
||||
# if !defined (_STLP_VERBOSE_RETURN_0)
|
||||
# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \
|
||||
_STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__, __LINE__); \
|
||||
return 0; }
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_INTERNAL_THREADS_H
|
||||
# include <stl/_threads.h>
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_INTERNAL_ITERATOR_BASE_H
|
||||
# include <stl/_iterator_base.h>
|
||||
# endif
|
||||
|
||||
# ifndef _STLP_TYPE_TRAITS_H
|
||||
# include <stl/type_traits.h>
|
||||
# endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
/*
|
||||
* Special debug iterator traits having an additionnal static member
|
||||
* method _Check. It is used by the slist debug implementation to check
|
||||
* the special before_begin iterator.
|
||||
*/
|
||||
template <class _Traits>
|
||||
struct _DbgTraits : _Traits {
|
||||
typedef _DbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
|
||||
typedef _DbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
|
||||
|
||||
template <class _Iterator>
|
||||
static bool _Check(const _Iterator&) {return true;}
|
||||
};
|
||||
|
||||
//=============================================================
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
|
||||
const random_access_iterator_tag&)
|
||||
{ return (__i1 < __i2) || (__i1 == __i2); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
|
||||
const bidirectional_iterator_tag&) {
|
||||
// check if comparable
|
||||
bool __dummy(__i1==__i2);
|
||||
return (__dummy==__dummy);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1 ,const _Iterator& __i2,
|
||||
const forward_iterator_tag&) {
|
||||
// check if comparable
|
||||
bool __dummy(__i1==__i2);
|
||||
return (__dummy==__dummy);
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&,
|
||||
const input_iterator_tag&)
|
||||
{ return true; }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator&,const _Iterator&,
|
||||
const output_iterator_tag&)
|
||||
{ return true; }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __valid_range(const _Iterator& __i1, const _Iterator& __i2)
|
||||
{ return __valid_range(__i1,__i2,_STLP_ITERATOR_CATEGORY(__i1, _Iterator)); }
|
||||
|
||||
// Note : that means in range [i1, i2].
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL stlp_in_range(const _Iterator& _It,
|
||||
const _Iterator& __i1, const _Iterator& __i2)
|
||||
{ return __valid_range(__i1,_It) && __valid_range(_It,__i2); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL stlp_in_range(const _Iterator& __first, const _Iterator& __last,
|
||||
const _Iterator& __start, const _Iterator& __finish)
|
||||
{ return __valid_range(__first,__last) && __valid_range(__start,__first) && __valid_range(__last,__finish); }
|
||||
|
||||
//==========================================================
|
||||
class _STLP_CLASS_DECLSPEC __owned_link {
|
||||
public:
|
||||
// Note: This and the following special defines for compiling under Windows CE under ARM
|
||||
// is needed for correctly using _STLP_DEBUG mode. This comes from a bug in the ARM
|
||||
// compiler where checked iterators that are passed by value call _M_attach with the wrong
|
||||
// this pointer and calling _M_detach can't find the correct pointer to the __owned_link.
|
||||
// This is circumvented by managing a _M_self pointer that points to the correct value.
|
||||
// Ugly but works.
|
||||
#if defined(_STLP_WCE) && defined(_ARM_)
|
||||
__owned_link() : _M_self(this), _M_owner(0) {}
|
||||
__owned_link(const __owned_list* __c) : _M_self(this), _M_owner(0), _M_next(0)
|
||||
{ __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); }
|
||||
__owned_link(const __owned_link& __rhs): _M_self(this), _M_owner(0)
|
||||
{ __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); }
|
||||
#else
|
||||
__owned_link() : _M_owner(0) {}
|
||||
__owned_link(const __owned_list* __c) : _M_owner(0), _M_next(0)
|
||||
{ __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__c), this); }
|
||||
__owned_link(const __owned_link& __rhs): _M_owner(0)
|
||||
{ __stl_debugger::_M_attach(__CONST_CAST(__owned_list*,__rhs._M_owner), this); }
|
||||
#endif
|
||||
__owned_link& operator=(const __owned_link& __rhs) {
|
||||
__owned_list* __new_owner = __CONST_CAST(__owned_list*,__rhs._M_owner);
|
||||
__owned_list* __old_owner = _M_owner;
|
||||
if ( __old_owner != __new_owner ) {
|
||||
__stl_debugger::_M_detach(__old_owner, this);
|
||||
__stl_debugger::_M_attach(__new_owner, this);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
#if defined(_STLP_WCE) && defined(_ARM_)
|
||||
~__owned_link() {
|
||||
__stl_debugger::_M_detach(_M_owner, _M_self);
|
||||
_Invalidate();
|
||||
}
|
||||
#else
|
||||
~__owned_link() {
|
||||
__stl_debugger::_M_detach(_M_owner, this);
|
||||
_Invalidate();
|
||||
}
|
||||
#endif
|
||||
|
||||
const __owned_list* _Owner() const { return _M_owner; }
|
||||
__owned_list* _Owner() { return _M_owner; }
|
||||
void _Set_owner(const __owned_list* __o) { _M_owner= __CONST_CAST(__owned_list*,__o); }
|
||||
bool _Valid() const { return _M_owner != 0; }
|
||||
void _Invalidate() { _M_owner = 0; _M_next = 0; }
|
||||
void _Link_to_self() { _M_next = 0; }
|
||||
|
||||
__owned_link* _Next() { return _M_next; }
|
||||
const __owned_link* _Next() const { return _M_next; }
|
||||
|
||||
public:
|
||||
#if defined(_STLP_WCE) && defined(_ARM_)
|
||||
__owned_link* _M_self;
|
||||
#endif
|
||||
|
||||
__owned_list* _M_owner;
|
||||
__owned_link* _M_next;
|
||||
};
|
||||
|
||||
|
||||
class _STLP_CLASS_DECLSPEC __owned_list {
|
||||
public:
|
||||
__owned_list(void* __o) {
|
||||
// fprintf(stderr, "__owned_list(): %p\n",(void*)this);
|
||||
_M_node._M_owner = __REINTERPRET_CAST(__owned_list*,__o);
|
||||
_M_node._M_next = 0;
|
||||
}
|
||||
~__owned_list() {
|
||||
// fprintf(stderr, "~__owned_list(): %p\n",(void*)this);
|
||||
_Invalidate_all();
|
||||
// that prevents detach
|
||||
_M_node._Invalidate();
|
||||
}
|
||||
const void* _Owner() const { return (const void*)_M_node._M_owner; }
|
||||
void* _Owner() { return (void*)_M_node._M_owner; }
|
||||
bool _Valid() const { return _M_node._M_owner != 0; }
|
||||
void _Invalidate() { _M_node._M_owner = 0; }
|
||||
|
||||
__owned_link* _First() { return _M_node._Next(); }
|
||||
__owned_link* _Last() { return 0 ; }
|
||||
|
||||
const __owned_link* _First() const { return (__owned_link*)_M_node._M_next; }
|
||||
const __owned_link* _Last() const { return 0 ;}
|
||||
|
||||
void _Verify() const { __stl_debugger::_Verify(this); }
|
||||
void _Swap_owners(__owned_list& __y) { __stl_debugger::_Swap_owners(*this, __y); }
|
||||
void _Invalidate_all() { __stl_debugger::_Invalidate_all(this); }
|
||||
void _Set_owner(__owned_list& __y) { __stl_debugger::_Set_owner(*this, __y); }
|
||||
|
||||
mutable __owned_link _M_node;
|
||||
mutable _STLP_mutex _M_lock;
|
||||
|
||||
private:
|
||||
// should never be called, should be left not implemented,
|
||||
// but some compilers complain about it ;(
|
||||
__owned_list(const __owned_list&){}
|
||||
__owned_list& operator = (const __owned_list&) { return *this; }
|
||||
|
||||
friend class __owned_link;
|
||||
friend class __stl_debug_engine<bool>;
|
||||
};
|
||||
|
||||
|
||||
//==========================================================
|
||||
|
||||
// forward declaratioins
|
||||
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&, const _Iterator&);
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&,
|
||||
const _Iterator&, const _Iterator&);
|
||||
template <class _Iterator>
|
||||
bool _STLP_CALL __check_range(const _Iterator&, const _Iterator& ,
|
||||
const _Iterator&, const _Iterator& );
|
||||
template <class _Tp>
|
||||
bool _STLP_CALL __check_ptr_range(const _Tp*, const _Tp*);
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_range(const __owned_list* __base,
|
||||
const _Iterator& __first,
|
||||
const _Iterator& __last);
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __invalidate_iterator(const __owned_list* __base,
|
||||
const _Iterator& __it);
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __change_range_owner(const _Iterator& __first,
|
||||
const _Iterator& __last,
|
||||
const __owned_list* __dst);
|
||||
|
||||
template <class _Iterator>
|
||||
void _STLP_CALL __change_ite_owner(const _Iterator& __it,
|
||||
const __owned_list* __dst);
|
||||
|
||||
//============================================================
|
||||
inline bool _STLP_CALL
|
||||
__check_same_owner(const __owned_link& __i1, const __owned_link& __i2)
|
||||
{ return __stl_debugger::_Check_same_owner(__i1,__i2); }
|
||||
|
||||
inline bool _STLP_CALL
|
||||
__check_same_or_null_owner(const __owned_link& __i1, const __owned_link& __i2)
|
||||
{ return __stl_debugger::_Check_same_or_null_owner(__i1,__i2); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __check_if_owner( const __owned_list* __owner,
|
||||
const _Iterator& __it)
|
||||
{ return __stl_debugger::_Check_if_owner(__owner, (const __owned_link&)__it); }
|
||||
|
||||
template <class _Iterator>
|
||||
inline bool _STLP_CALL __check_if_not_owner( const __owned_list* __owner,
|
||||
const _Iterator& __it)
|
||||
{ return __stl_debugger::_Check_if_not_owner(__owner, (const __owned_link&)__it); }
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#else
|
||||
# define _STLP_VERBOSE_ASSERT(expr, diagnostic)
|
||||
# define _STLP_DEBUG_CHECK(expr)
|
||||
#endif /* _STLP_DEBUG */
|
||||
|
||||
#if defined (_STLP_ASSERTIONS)
|
||||
|
||||
# if !defined (_STLP_ASSERT_MSG_TRAILER)
|
||||
# define _STLP_ASSERT_MSG_TRAILER
|
||||
# endif
|
||||
|
||||
// dwa 12/30/98 - if _STLP_DEBUG_MESSAGE is defined, the user can supply own definition.
|
||||
# if !defined (_STLP_DEBUG_MESSAGE)
|
||||
# define __stl_debug_message __stl_debugger::_Message
|
||||
# else
|
||||
extern void __stl_debug_message(const char * format_str, ...);
|
||||
# endif
|
||||
|
||||
// fbp: if _STLP_DEBUG_TERMINATE is defined, the user can supply own definition.
|
||||
# if !defined (_STLP_DEBUG_TERMINATE)
|
||||
# define __stl_debug_terminate __stl_debugger::_Terminate
|
||||
# else
|
||||
extern void __stl_debug_terminate();
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_ASSERTIONS) && !defined (_STLP_LINK_TIME_INSTANTIATION)
|
||||
# include <stl/debug/_debug.c>
|
||||
#endif
|
||||
|
||||
#endif /* DEBUG_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
414
extern/STLport/5.2.1/stlport/stl/debug/_deque.h
vendored
Normal file
414
extern/STLport/5.2.1/stlport/stl/debug/_deque.h
vendored
Normal file
@@ -0,0 +1,414 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_DEQUE_H
|
||||
#define _STLP_INTERNAL_DBG_DEQUE_H
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
#define _STLP_NON_DBG_DEQUE _STLP_PRIV _STLP_NON_DBG_NAME(deque) <_Tp,_Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp* value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
|
||||
{ return (_Tp*)0; }
|
||||
template <class _Tp, class _Alloc>
|
||||
inline random_access_iterator_tag iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
|
||||
{ return random_access_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
|
||||
class deque :
|
||||
#if !defined (__DMC__)
|
||||
private
|
||||
#endif
|
||||
_STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
, public __stlport_class<deque<_Tp, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef deque<_Tp,_Alloc> _Self;
|
||||
typedef _STLP_NON_DBG_DEQUE _Base;
|
||||
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > _ConstructCheck;
|
||||
|
||||
public:
|
||||
// Basic types
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
// Iterators
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
|
||||
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
protected:
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
void _Invalidate_all()
|
||||
{ _M_iter_list._Invalidate_all(); }
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); }
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
public:
|
||||
// Basic accessors
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_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) {
|
||||
_STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
const_reference operator[](size_type __n) const {
|
||||
_STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
|
||||
reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
|
||||
const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
|
||||
|
||||
reference front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
const_reference front() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
reference back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
const_reference back() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
|
||||
// Constructor, destructor.
|
||||
explicit deque(const allocator_type& __a = allocator_type()) :
|
||||
_M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
deque(const _Self& __x) :
|
||||
_ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit deque(size_type __n, const value_type& __x = _Tp(),
|
||||
#else
|
||||
deque(size_type __n, const value_type& __x,
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
const allocator_type& __a = allocator_type()) :
|
||||
_M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit deque(size_type __n) :
|
||||
_M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
deque(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
deque(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
deque(_InputIterator __first, _InputIterator __last)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
# endif
|
||||
#else
|
||||
deque(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first, __last, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
|
||||
deque(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
#endif
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
if (this != &__x) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl = __x._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__x._M_non_dbg_impl);
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
public:
|
||||
void assign(size_type __n, const _Tp& __val) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__n, __val);
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#else
|
||||
void assign(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void assign(const value_type *__first, const value_type *__last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
public: // push_* and pop_*
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
void push_back(const value_type& __t = _Tp()) {
|
||||
#else
|
||||
void push_back(const value_type& __t) {
|
||||
#endif
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.push_back(__t);
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
void push_back() {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.push_back();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
void push_front(const value_type& __t = _Tp()) {
|
||||
#else
|
||||
void push_front(const value_type& __t) {
|
||||
#endif
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.push_front(__t);
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
void push_front() {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.push_front();
|
||||
}
|
||||
#endif
|
||||
|
||||
void pop_back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Invalidate_iterator(end());
|
||||
_M_non_dbg_impl.pop_back();
|
||||
}
|
||||
|
||||
void pop_front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Invalidate_iterator(begin());
|
||||
_M_non_dbg_impl.pop_front();
|
||||
}
|
||||
|
||||
public: // Insert
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos, const value_type& __x = _Tp()) {
|
||||
#else
|
||||
iterator insert(iterator __pos, const value_type& __x) {
|
||||
#endif
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Invalidate_all();
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Invalidate_all();
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator));
|
||||
}
|
||||
#endif
|
||||
|
||||
void insert(iterator __pos, size_type __n, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
if (__n != 0) _Invalidate_all();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
// We perform invalidate first to detect self referencing in __check_range as __first and __last
|
||||
// will have been invalidated.
|
||||
if (__first != __last) _Invalidate_all();
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
void insert(iterator __pos,
|
||||
const value_type* __first, const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
if (__first != __last) _Invalidate_all();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
void insert(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
//Sequence requirements 23.1.1 Table 67:
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
|
||||
if (__first != __last) _Invalidate_all();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void insert(iterator __pos,
|
||||
iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
//Sequence requirements 23.1.1 Table 67:
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
|
||||
if (__first != __last) _Invalidate_all();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size, const value_type& __x = _Tp()) {
|
||||
#else
|
||||
void resize(size_type __new_size, const value_type& __x) {
|
||||
#endif
|
||||
if (__new_size != size()) {
|
||||
if ((__new_size > size()) || (__new_size < size() - 1))
|
||||
_Invalidate_all();
|
||||
else
|
||||
_Invalidate_iterator(end());
|
||||
}
|
||||
_M_non_dbg_impl.resize(__new_size, __x);
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif
|
||||
|
||||
// Erase
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
if (__pos._M_iterator == _M_non_dbg_impl.begin()) {
|
||||
_Invalidate_iterator(__pos);
|
||||
} else {
|
||||
typename _Base::iterator tmp = --(_M_non_dbg_impl.end());
|
||||
if (__pos._M_iterator == tmp)
|
||||
_Invalidate_iterator(__pos);
|
||||
else
|
||||
_Invalidate_all();
|
||||
}
|
||||
return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
|
||||
}
|
||||
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
if (!empty()) {
|
||||
if (__first._M_iterator == _M_non_dbg_impl.begin() ||
|
||||
__last._M_iterator == _M_non_dbg_impl.end())
|
||||
_Invalidate_iterators(__first, __last);
|
||||
else
|
||||
_Invalidate_all();
|
||||
}
|
||||
return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_DEQUE
|
||||
|
||||
#endif /* _STLP_INTERNAL_DEQUE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
340
extern/STLport/5.2.1/stlport/stl/debug/_hashtable.h
vendored
Normal file
340
extern/STLport/5.2.1/stlport/stl/debug/_hashtable.h
vendored
Normal file
@@ -0,0 +1,340 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_HASHTABLE_H
|
||||
#define _STLP_INTERNAL_DBG_HASHTABLE_H
|
||||
|
||||
// Hashtable class, used to implement the hashed associative containers
|
||||
// hash_set, hash_map, hash_multiset, and hash_multimap,
|
||||
// unordered_set, unordered_map, unordered_multiset, unordered_multimap
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Key, class _Equal>
|
||||
class _DbgEqual {
|
||||
public:
|
||||
_DbgEqual() {}
|
||||
_DbgEqual(const _Equal& __eq) : _M_non_dbg_eq(__eq) {}
|
||||
_DbgEqual(const _DbgEqual& __eq) : _M_non_dbg_eq(__eq._M_non_dbg_eq) {}
|
||||
|
||||
#if !defined (_STLP_USE_CONTAINERS_EXTENSION)
|
||||
bool operator () (const _Key& __lhs, const _Key& __rhs) const
|
||||
#else
|
||||
template <class _Kp1, class _Kp2>
|
||||
bool operator () (const _Kp1& __lhs, const _Kp2& __rhs) const
|
||||
#endif
|
||||
{
|
||||
#if !defined (_STLP_USE_CONTAINERS_EXTENSION)
|
||||
_STLP_VERBOSE_ASSERT(_M_non_dbg_eq(__rhs, __lhs) == _M_non_dbg_eq(__lhs, __rhs), _StlMsg_INVALID_EQUIVALENT_PREDICATE)
|
||||
#endif
|
||||
return _M_non_dbg_eq(__lhs, __rhs) ? true : false;
|
||||
}
|
||||
|
||||
_Equal non_dbg_key_eq() const { return _M_non_dbg_eq; }
|
||||
private:
|
||||
_Equal _M_non_dbg_eq;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
#define _STLP_NON_DBG_HT \
|
||||
_STLP_PRIV _STLP_NON_DBG_NAME(hashtable) <_Val, _Key, _HF, _Traits, _ExK, _STLP_PRIV _DbgEqual<_Key, _EqK>, _All>
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _ExK, class _EqK, class _All>
|
||||
inline _Val*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_HT >&)
|
||||
{ return (_Val*)0; }
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _ExK, class _EqK, class _All>
|
||||
inline forward_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_HT >&)
|
||||
{ return forward_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
template <class _Val, class _Key, class _HF,
|
||||
class _Traits, class _ExK, class _EqK, class _All>
|
||||
class hashtable {
|
||||
typedef hashtable<_Val, _Key, _HF, _Traits, _ExK, _EqK, _All> _Self;
|
||||
typedef _STLP_NON_DBG_HT _Base;
|
||||
|
||||
typedef typename _Traits::_NonConstTraits _NonConstTraits;
|
||||
typedef typename _Traits::_ConstTraits _ConstTraits;
|
||||
typedef typename _Traits::_NonConstLocalTraits _NonConstLocalTraits;
|
||||
typedef typename _Traits::_ConstLocalTraits _ConstLocalTraits;
|
||||
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
public:
|
||||
typedef _Key key_type;
|
||||
typedef _HF hasher;
|
||||
typedef _EqK key_equal;
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_NonConstTraits> > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_ConstTraits> > const_iterator;
|
||||
//typedef _STLP_PRIV _DBG_iter<_Base, _DbgTraits<_NonConstLocalTraits> > local_iterator;
|
||||
typedef iterator local_iterator;
|
||||
//typedef _STLP_PRIV _DBG_iter<_Base, _DbgTraits<_ConstLocalTraits> > const_local_iterator;
|
||||
typedef const_iterator const_local_iterator;
|
||||
|
||||
typedef typename _Base::iterator _Base_iterator;
|
||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||
|
||||
hasher hash_funct() const { return _M_non_dbg_impl.hash_funct(); }
|
||||
key_equal key_eq() const { return _M_non_dbg_impl.key_eq().non_dbg_key_eq(); }
|
||||
|
||||
private:
|
||||
void _Invalidate_iterator(const const_iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
|
||||
void _Invalidate_iterators(const const_iterator& __first, const const_iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
|
||||
public:
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
|
||||
hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const _ExK& __ext,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __hf, __eql, __ext, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
hashtable(size_type __n,
|
||||
const _HF& __hf,
|
||||
const _EqK& __eql,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __hf, __eql, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
hashtable(const _Self& __ht)
|
||||
: _M_non_dbg_impl(__ht._M_non_dbg_impl),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
hashtable(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
|
||||
_Self& operator=(const _Self& __ht) {
|
||||
if (this != &__ht) {
|
||||
//Should not invalidate end iterator
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl = __ht._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void swap(_Self& __ht) {
|
||||
_M_iter_list._Swap_owners(__ht._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__ht._M_non_dbg_impl);
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
local_iterator begin(size_type __n) {
|
||||
//TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators
|
||||
_STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT)
|
||||
return local_iterator(&_M_iter_list, _M_non_dbg_impl.begin(__n));
|
||||
}
|
||||
local_iterator end(size_type __n) {
|
||||
//TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators
|
||||
_STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT)
|
||||
return local_iterator(&_M_iter_list, _M_non_dbg_impl.end(__n));
|
||||
}
|
||||
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_local_iterator begin(size_type __n) const {
|
||||
//TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators
|
||||
_STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT)
|
||||
return const_local_iterator(&_M_iter_list, _M_non_dbg_impl.begin(__n));
|
||||
}
|
||||
const_local_iterator end(size_type __n) const {
|
||||
//TODO: Add checks for iterator locality -> avoids comparison between different bucket iterators
|
||||
_STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT)
|
||||
return const_local_iterator(&_M_iter_list, _M_non_dbg_impl.end(__n));
|
||||
}
|
||||
|
||||
pair<iterator, bool> insert_unique(const value_type& __obj) {
|
||||
pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique(__obj);
|
||||
return pair<iterator, bool>(iterator(&_M_iter_list, __res.first), __res.second);
|
||||
}
|
||||
|
||||
iterator insert_equal(const value_type& __obj)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__obj)); }
|
||||
|
||||
pair<iterator, bool> insert_unique_noresize(const value_type& __obj) {
|
||||
pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique_noresize(__obj);
|
||||
return pair<iterator, bool>(iterator(&_M_iter_list, __res.first), __res.second);
|
||||
}
|
||||
|
||||
iterator insert_equal_noresize(const value_type& __obj)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal_noresize(__obj)); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert_unique(_InputIterator __f, _InputIterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_unique(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
|
||||
}
|
||||
|
||||
template <class _InputIterator>
|
||||
void insert_equal(_InputIterator __f, _InputIterator __l){
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_equal(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
|
||||
}
|
||||
|
||||
#else
|
||||
void insert_unique(const value_type* __f, const value_type* __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_unique(__f, __l);
|
||||
}
|
||||
|
||||
void insert_equal(const value_type* __f, const value_type* __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_equal(__f, __l);
|
||||
}
|
||||
|
||||
void insert_unique(const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_unique(__f._M_iterator, __l._M_iterator);
|
||||
}
|
||||
|
||||
void insert_equal(const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
_M_non_dbg_impl.insert_equal(__f._M_iterator, __l._M_iterator);
|
||||
}
|
||||
#endif
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __key)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.find(__key)); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __key) const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.find(__key)); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __key) const { return _M_non_dbg_impl.count(__key); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator, iterator> equal_range(const _KT& __key) {
|
||||
pair<_Base_iterator, _Base_iterator> __res = _M_non_dbg_impl.equal_range(__key);
|
||||
return pair<iterator,iterator> (iterator(&_M_iter_list,__res.first),
|
||||
iterator(&_M_iter_list,__res.second));
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __key) const {
|
||||
pair <_Base_const_iterator, _Base_const_iterator> __res = _M_non_dbg_impl.equal_range(__key);
|
||||
return pair<const_iterator,const_iterator> (const_iterator(&_M_iter_list,__res.first),
|
||||
const_iterator(&_M_iter_list,__res.second));
|
||||
}
|
||||
|
||||
size_type erase(const key_type& __key) {
|
||||
pair<iterator, iterator> __p = equal_range(__key);
|
||||
size_type __n = _STLP_STD::distance(__p.first, __p.second);
|
||||
_Invalidate_iterators(__p.first, __p.second);
|
||||
_M_non_dbg_impl.erase(__p.first._M_iterator, __p.second._M_iterator);
|
||||
return __n;
|
||||
}
|
||||
|
||||
void erase(const const_iterator& __it) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__it))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __it))
|
||||
_Invalidate_iterator(__it);
|
||||
_M_non_dbg_impl.erase(__it._M_iterator);
|
||||
}
|
||||
void erase(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last,
|
||||
const_iterator(begin()), const_iterator(end())))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
_M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void rehash(size_type __num_buckets_hint) { _M_non_dbg_impl.rehash(__num_buckets_hint); }
|
||||
void resize(size_type __num_elements_hint) { _M_non_dbg_impl.resize(__num_elements_hint); }
|
||||
|
||||
void clear() {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
|
||||
reference _M_insert(const value_type& __obj) { return _M_non_dbg_impl._M_insert(__obj); }
|
||||
|
||||
size_type bucket_count() const { return _M_non_dbg_impl.bucket_count(); }
|
||||
size_type max_bucket_count() const { return _M_non_dbg_impl.max_bucket_count(); }
|
||||
size_type elems_in_bucket(size_type __n) const {
|
||||
_STLP_VERBOSE_ASSERT((__n < bucket_count()), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.elems_in_bucket(__n);
|
||||
}
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type bucket(const _KT& __k) const { return _M_non_dbg_impl.bucket(__k); }
|
||||
|
||||
float load_factor() const { return _M_non_dbg_impl.load_factor(); }
|
||||
float max_load_factor() const { return _M_non_dbg_impl.max_load_factor(); }
|
||||
void max_load_factor(float __z) {
|
||||
_STLP_VERBOSE_ASSERT((__z > 0.0f), _StlMsg_INVALID_ARGUMENT)
|
||||
_M_non_dbg_impl.max_load_factor(__z);
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_HT
|
||||
|
||||
#endif /* _STLP_INTERNAL_HASHTABLE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
457
extern/STLport/5.2.1/stlport/stl/debug/_iterator.h
vendored
Normal file
457
extern/STLport/5.2.1/stlport/stl/debug/_iterator.h
vendored
Normal file
@@ -0,0 +1,457 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
#define _STLP_DBG_ITERATOR_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_PAIR_H
|
||||
# include <stl/_pair.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
//============================================================
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const bidirectional_iterator_tag &)
|
||||
{ --__it; }
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const random_access_iterator_tag &)
|
||||
{ --__it; }
|
||||
|
||||
template <class _Iterator>
|
||||
void _Decrement(_Iterator& __it, const forward_iterator_tag &)
|
||||
{ _STLP_ASSERT(0) }
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator&, ptrdiff_t, const forward_iterator_tag &)
|
||||
{ _STLP_ASSERT(0) }
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator& __it, ptrdiff_t, const bidirectional_iterator_tag &)
|
||||
{ _STLP_ASSERT(0) }
|
||||
|
||||
template <class _Iterator>
|
||||
void _Advance(_Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &)
|
||||
{ __it += __n; }
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &)
|
||||
{ return __x - __y; }
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
ptrdiff_t _DBG_distance(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator&, const _Iterator&, const forward_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator&, const _Iterator&, const bidirectional_iterator_tag &) {
|
||||
_STLP_ASSERT(0)
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _CompareIt(const _Iterator& __x, const _Iterator& __y, const random_access_iterator_tag &)
|
||||
{ return __x < __y; }
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Dereferenceable(const _Iterator& __it)
|
||||
{ return (__it._Get_container_ptr() != 0) && !(__it._M_iterator == (__it._Get_container_ptr())->end()); }
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const forward_iterator_tag &)
|
||||
{ return (__n == 1) && _Dereferenceable(__it); }
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const bidirectional_iterator_tag &) {
|
||||
typedef typename _Iterator::_Container_type __container_type;
|
||||
__container_type* __c = __it._Get_container_ptr();
|
||||
return (__c != 0) && ((__n == 1 && __it._M_iterator != __c->end() ) ||
|
||||
(__n == -1 && __it._M_iterator != __c->begin()));
|
||||
}
|
||||
|
||||
template <class _Iterator>
|
||||
bool _Incrementable(const _Iterator& __it, ptrdiff_t __n, const random_access_iterator_tag &) {
|
||||
typedef typename _Iterator::_Container_type __container_type;
|
||||
__container_type* __c = __it._Get_container_ptr();
|
||||
if (__c == 0) return false;
|
||||
ptrdiff_t __new_pos = (__it._M_iterator - __c->begin()) + __n;
|
||||
return (__new_pos >= 0) && (__STATIC_CAST(typename __container_type::size_type, __new_pos) <= __c->size());
|
||||
}
|
||||
|
||||
|
||||
template <class _Container>
|
||||
struct _DBG_iter_base : public __owned_link {
|
||||
public:
|
||||
typedef typename _Container::value_type value_type;
|
||||
typedef typename _Container::reference reference;
|
||||
typedef typename _Container::pointer pointer;
|
||||
typedef ptrdiff_t difference_type;
|
||||
//private:
|
||||
typedef typename _Container::iterator _Nonconst_iterator;
|
||||
typedef typename _Container::const_iterator _Const_iterator;
|
||||
typedef _Container _Container_type;
|
||||
|
||||
#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef typename iterator_traits<_Const_iterator>::iterator_category _Iterator_category;
|
||||
#else
|
||||
typedef typename _Container::_Iterator_category _Iterator_category;
|
||||
#endif
|
||||
typedef _Iterator_category iterator_category;
|
||||
|
||||
_DBG_iter_base() : __owned_link(0) {}
|
||||
_DBG_iter_base(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
#if defined(__HP_aCC) && (__HP_aCC < 60000)
|
||||
__owned_link(__c), _M_iterator(*__REINTERPRET_CAST(const _Nonconst_iterator *, &__it)) {}
|
||||
#else
|
||||
__owned_link(__c), _M_iterator(*(const _Nonconst_iterator*)&__it) {}
|
||||
#endif
|
||||
_Container* _Get_container_ptr() const {
|
||||
return (_Container*)__stl_debugger::_Get_container_ptr(this);
|
||||
}
|
||||
|
||||
void __increment();
|
||||
void __decrement();
|
||||
void __advance(ptrdiff_t __n);
|
||||
|
||||
// protected:
|
||||
_Nonconst_iterator _M_iterator;
|
||||
};
|
||||
|
||||
template <class _Container>
|
||||
inline void _DBG_iter_base<_Container>::__increment() {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this, 1, _Iterator_category()))
|
||||
++_M_iterator;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline void _DBG_iter_base<_Container>::__decrement() {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this, -1, _Iterator_category()))
|
||||
_Decrement(_M_iterator, _Iterator_category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline void _DBG_iter_base<_Container>::__advance(ptrdiff_t __n) {
|
||||
_STLP_DEBUG_CHECK(_Incrementable(*this, __n, _Iterator_category()))
|
||||
_Advance(_M_iterator, __n, _Iterator_category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
ptrdiff_t operator-(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y ) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Iterator_category;
|
||||
_STLP_DEBUG_CHECK(__check_same_owner(__x, __y))
|
||||
return _DBG_distance(__x._M_iterator,__y._M_iterator, _Iterator_category());
|
||||
}
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
struct _DBG_iter_mid : public _DBG_iter_base<_Container> {
|
||||
typedef _DBG_iter_mid<_Container, typename _Traits::_NonConstTraits> _Nonconst_self;
|
||||
typedef typename _Container::iterator _Nonconst_iterator;
|
||||
typedef typename _Container::const_iterator _Const_iterator;
|
||||
|
||||
_DBG_iter_mid() {}
|
||||
|
||||
explicit _DBG_iter_mid(const _Nonconst_self& __it) :
|
||||
_DBG_iter_base<_Container>(__it) {}
|
||||
|
||||
_DBG_iter_mid(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
_DBG_iter_base<_Container>(__c, __it) {}
|
||||
};
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
struct _DBG_iter : public _DBG_iter_mid<_Container, _Traits> {
|
||||
typedef _DBG_iter_base<_Container> _Base;
|
||||
public:
|
||||
typedef typename _Base::value_type value_type;
|
||||
typedef typename _Base::difference_type difference_type;
|
||||
typedef typename _Traits::reference reference;
|
||||
typedef typename _Traits::pointer pointer;
|
||||
|
||||
typedef typename _Base::_Nonconst_iterator _Nonconst_iterator;
|
||||
typedef typename _Base::_Const_iterator _Const_iterator;
|
||||
|
||||
private:
|
||||
typedef _DBG_iter<_Container, _Traits> _Self;
|
||||
typedef _DBG_iter_mid<_Container, typename _Traits::_NonConstTraits> _Nonconst_mid;
|
||||
|
||||
public:
|
||||
|
||||
#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
|
||||
typedef typename _Base::iterator_category iterator_category;
|
||||
#endif
|
||||
typedef typename _Base::_Iterator_category _Iterator_category;
|
||||
|
||||
public:
|
||||
_DBG_iter() {}
|
||||
// boris : real type of iter would be nice
|
||||
_DBG_iter(const __owned_list* __c, const _Const_iterator& __it) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__c, __it) {}
|
||||
|
||||
// This allows conversions from iterator to const_iterator without being
|
||||
// redundant with the copy constructor below.
|
||||
_DBG_iter(const _Nonconst_mid& __rhs) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__rhs) {}
|
||||
|
||||
_DBG_iter(const _Self& __rhs) :
|
||||
_DBG_iter_mid<_Container, _Traits>(__rhs) {}
|
||||
|
||||
// This allows conversions from iterator to const_iterator without being
|
||||
// redundant with the copy assignment operator below.
|
||||
_Self& operator=(const _Nonconst_mid& __rhs) {
|
||||
(_Base&)*this = __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator=(const _Self& __rhs) {
|
||||
(_Base&)*this = __rhs;
|
||||
return *this;
|
||||
}
|
||||
|
||||
reference operator*() const;
|
||||
|
||||
_STLP_DEFINE_ARROW_OPERATOR
|
||||
|
||||
_Self& operator++() {
|
||||
this->__increment();
|
||||
return *this;
|
||||
}
|
||||
_Self operator++(int) {
|
||||
_Self __tmp = *this;
|
||||
this->__increment();
|
||||
return __tmp;
|
||||
}
|
||||
_Self& operator--() {
|
||||
this->__decrement();
|
||||
return *this;
|
||||
}
|
||||
_Self operator--(int) {
|
||||
_Self __tmp = *this;
|
||||
this->__decrement();
|
||||
return __tmp;
|
||||
}
|
||||
|
||||
_Self& operator+=(difference_type __n) {
|
||||
this->__advance(__n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator-=(difference_type __n) {
|
||||
this->__advance(-__n);
|
||||
return *this;
|
||||
}
|
||||
_Self operator+(difference_type __n) const {
|
||||
_Self __tmp(*this);
|
||||
__tmp.__advance(__n);
|
||||
return __tmp;
|
||||
}
|
||||
_Self operator-(difference_type __n) const {
|
||||
_Self __tmp(*this);
|
||||
__tmp.__advance(-__n);
|
||||
return __tmp;
|
||||
}
|
||||
reference operator[](difference_type __n) const { return *(*this + __n); }
|
||||
};
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
inline
|
||||
#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
|
||||
_STLP_TYPENAME_ON_RETURN_TYPE _Traits::reference
|
||||
#else
|
||||
_STLP_TYPENAME_ON_RETURN_TYPE _DBG_iter<_Container, _Traits>::reference
|
||||
#endif
|
||||
_DBG_iter<_Container, _Traits>::operator*() const {
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(*this))
|
||||
_STLP_DEBUG_CHECK(_Traits::_Check(*this))
|
||||
return *this->_M_iterator;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator==(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y))
|
||||
return __x._M_iterator == __y._M_iterator;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator<(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y))
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _CompareIt(__x._M_iterator , __y._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator>(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _CompareIt(__y._M_iterator , __x._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator>=(const _DBG_iter_base<_Container>& __x, const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y))
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return !_CompareIt(__x._M_iterator , __y._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator<=(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
typedef typename _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return !_CompareIt(__y._M_iterator , __x._M_iterator, _Category());
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline bool
|
||||
operator!=(const _DBG_iter_base<_Container>& __x,
|
||||
const _DBG_iter_base<_Container>& __y) {
|
||||
_STLP_DEBUG_CHECK(__check_same_or_null_owner(__x, __y))
|
||||
return __x._M_iterator != __y._M_iterator;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
template <class _Container, class _Traits>
|
||||
inline _DBG_iter<_Container, _Traits>
|
||||
operator+(ptrdiff_t __n, const _DBG_iter<_Container, _Traits>& __it) {
|
||||
_DBG_iter<_Container, _Traits> __tmp(__it);
|
||||
return __tmp += __n;
|
||||
}
|
||||
|
||||
|
||||
template <class _Iterator>
|
||||
inline _Iterator _Non_Dbg_iter(_Iterator __it)
|
||||
{ return __it; }
|
||||
|
||||
#if defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
template <class _Container, class _Traits>
|
||||
inline typename _DBG_iter<_Container, _Traits>::_Nonconst_iterator
|
||||
_Non_Dbg_iter(const _DBG_iter<_Container, _Traits>& __it)
|
||||
{ return __it._M_iterator; }
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Helper classes to check iterator range or pointer validity
|
||||
* at construction time.
|
||||
*/
|
||||
template <class _Container>
|
||||
class __construct_checker {
|
||||
typedef typename _Container::value_type value_type;
|
||||
protected:
|
||||
__construct_checker() {}
|
||||
|
||||
__construct_checker(const value_type* __p) {
|
||||
_STLP_VERBOSE_ASSERT((__p != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIter>
|
||||
__construct_checker(const _InputIter& __f, const _InputIter& __l) {
|
||||
typedef typename _IsIntegral<_InputIter>::_Ret _Integral;
|
||||
_M_check_dispatch(__f, __l, _Integral());
|
||||
}
|
||||
|
||||
template <class _Integer>
|
||||
void _M_check_dispatch(_Integer , _Integer, const __true_type& /*IsIntegral*/) {}
|
||||
|
||||
template <class _InputIter>
|
||||
void _M_check_dispatch(const _InputIter& __f, const _InputIter& __l, const __false_type& /*IsIntegral*/) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__f,__l))
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
__construct_checker(const value_type* __f, const value_type* __l) {
|
||||
_STLP_DEBUG_CHECK(__check_ptr_range(__f,__l))
|
||||
}
|
||||
|
||||
typedef _DBG_iter_base<_Container> _IteType;
|
||||
__construct_checker(const _IteType& __f, const _IteType& __l) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__f,__l))
|
||||
}
|
||||
#endif
|
||||
#if defined (__BORLANDC__)
|
||||
~__construct_checker(){}
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
|
||||
# if defined (_STLP_NESTED_TYPE_PARAM_BUG) ||\
|
||||
(defined (__SUNPRO_CC) && __SUNPRO_CC < 0x600)
|
||||
# define _STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS 1
|
||||
# endif
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Container>
|
||||
inline ptrdiff_t*
|
||||
distance_type(const _STLP_PRIV _DBG_iter_base<_Container>&) { return (ptrdiff_t*) 0; }
|
||||
|
||||
# if !defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Container>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _DBG_iter_base<_Container>::value_type*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base<_Container>&) {
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _DBG_iter_base<_Container>::value_type _Val;
|
||||
return (_Val*)0;
|
||||
}
|
||||
|
||||
template <class _Container>
|
||||
inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_PRIV _DBG_iter_base<_Container>::_Iterator_category
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base<_Container>&) {
|
||||
typedef _STLP_TYPENAME _STLP_PRIV _DBG_iter_base<_Container>::_Iterator_category _Category;
|
||||
return _Category();
|
||||
}
|
||||
# endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* INTERNAL_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
495
extern/STLport/5.2.1/stlport/stl/debug/_list.h
vendored
Normal file
495
extern/STLport/5.2.1/stlport/stl/debug/_list.h
vendored
Normal file
@@ -0,0 +1,495 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_LIST_H
|
||||
#define _STLP_INTERNAL_DBG_LIST_H
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALGO_H
|
||||
# include <stl/_algo.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
#define _STLP_NON_DBG_LIST _STLP_PRIV _STLP_NON_DBG_NAME(list) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&)
|
||||
{ return (_Tp*)0; }
|
||||
template <class _Tp, class _Alloc>
|
||||
inline bidirectional_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_LIST >&)
|
||||
{ return bidirectional_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
|
||||
class list :
|
||||
#if !defined (__DMC__)
|
||||
private
|
||||
#endif
|
||||
_STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
, public __stlport_class<list<_Tp, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
typedef _STLP_NON_DBG_LIST _Base;
|
||||
typedef list<_Tp, _Alloc> _Self;
|
||||
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_LIST > _ConstructCheck;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
public:
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
|
||||
|
||||
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
|
||||
|
||||
private:
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
typedef typename _Base::iterator _Base_iterator;
|
||||
|
||||
public:
|
||||
explicit list(const allocator_type& __a = allocator_type()) :
|
||||
_M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit list(size_type __n, const _Tp& __x = _Tp(),
|
||||
#else
|
||||
list(size_type __n, const _Tp& __x,
|
||||
#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit list(size_type __n)
|
||||
: _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
list(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
list(_InputIterator __first, _InputIterator __last)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# endif
|
||||
#else
|
||||
|
||||
list(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first, __last, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
list(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#endif
|
||||
|
||||
list(const _Self& __x) :
|
||||
_ConstructCheck(__x),
|
||||
_M_non_dbg_impl(__x._M_non_dbg_impl) , _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
if (this != &__x) {
|
||||
//Should not invalidate end iterator
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl = __x._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_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()); }
|
||||
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
|
||||
// those are here to enforce checking
|
||||
reference front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
const_reference front() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
reference back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
const_reference back() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__x._M_non_dbg_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_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos, const _Tp& __x = _Tp()) {
|
||||
#else
|
||||
iterator insert(iterator __pos, const _Tp& __x) {
|
||||
#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list,_M_non_dbg_impl.insert(__pos._M_iterator, __x) );
|
||||
}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
|
||||
iterator insert(iterator __pos) { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
void insert(iterator __pos, const _Tp* __first, const _Tp* __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
void insert(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
_STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first))
|
||||
# endif
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert(iterator __pos,
|
||||
iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
_STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __first))
|
||||
# endif
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
#endif
|
||||
|
||||
void insert(iterator __pos, size_type __n, const _Tp& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
void push_back(const_reference __x) { _M_non_dbg_impl.push_back(__x); }
|
||||
void pop_back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Invalidate_iterator(end());
|
||||
_M_non_dbg_impl.pop_back();
|
||||
}
|
||||
|
||||
void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); }
|
||||
void pop_front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Invalidate_iterator(begin());
|
||||
_M_non_dbg_impl.pop_front();
|
||||
}
|
||||
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_Invalidate_iterator(__pos);
|
||||
return iterator(&_M_iter_list,_M_non_dbg_impl.erase(__pos._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size, const _Tp& __x = _Tp()) {
|
||||
#else
|
||||
void resize(size_type __new_size, const _Tp& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
_Base_iterator __i = _M_non_dbg_impl.begin();
|
||||
size_type __len = 0;
|
||||
for ( ; __i != _M_non_dbg_impl.end() && __len < __new_size; ++__i, ++__len);
|
||||
|
||||
if (__len == __new_size)
|
||||
erase(iterator(&_M_iter_list, __i), end());
|
||||
else // __i == end()
|
||||
_M_non_dbg_impl.insert(_M_non_dbg_impl.end(), __new_size - __len, __x);
|
||||
}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
_Invalidate_iterators(begin(), end());
|
||||
}
|
||||
#else
|
||||
void assign(const _Tp* __first, const _Tp* __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_M_non_dbg_impl.assign(__first, __last);
|
||||
_Invalidate_iterators(begin(), end());
|
||||
}
|
||||
|
||||
void assign(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
|
||||
_Invalidate_iterators(begin(), end());
|
||||
}
|
||||
|
||||
void assign(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
|
||||
_Invalidate_iterators(begin(), end());
|
||||
}
|
||||
#endif
|
||||
|
||||
void assign(size_type __n, const _Tp& __val) {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.assign(__n, __val);
|
||||
}
|
||||
|
||||
void remove(const _Tp& __x) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
while (__first != __last) {
|
||||
_Base_iterator __next = __first;
|
||||
++__next;
|
||||
if (__x == *__first) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __first));
|
||||
_M_non_dbg_impl.erase(__first);
|
||||
}
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
|
||||
public:
|
||||
void splice(iterator __pos, _Self& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl);
|
||||
#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
|
||||
if (get_allocator() == __x.get_allocator())
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
else
|
||||
#endif
|
||||
// Std: 23.2.2.4:4
|
||||
// end iterator is not invalidated:
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
|
||||
void splice(iterator __pos, _Self& __x, iterator __i) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&(__x._M_iter_list),__i))
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator);
|
||||
#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
|
||||
if (get_allocator() == __x.get_allocator())
|
||||
_STLP_PRIV __change_ite_owner(__i, &_M_iter_list);
|
||||
else
|
||||
#endif
|
||||
// Std: 23.2.2.4:7
|
||||
__x._Invalidate_iterator(__i);
|
||||
}
|
||||
|
||||
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end()))
|
||||
_STLP_DEBUG_CHECK(this == &__x ? !_STLP_PRIV __check_range(__pos, __first, __last) : true)
|
||||
#if (_STLP_DEBUG_LEVEL != _STLP_STANDARD_DBG_LEVEL)
|
||||
if (this->get_allocator() == __x.get_allocator())
|
||||
_STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
|
||||
else
|
||||
#endif
|
||||
// Std: 23.2.2.4:12
|
||||
__x._Invalidate_iterators(__first, __last);
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void merge(_Self& __x) {
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
_STLP_DEBUG_CHECK(_STLP_STD::is_sorted(begin()._M_iterator, end()._M_iterator))
|
||||
_STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator))
|
||||
#endif
|
||||
_M_non_dbg_impl.merge(__x._M_non_dbg_impl);
|
||||
if (this->get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
void reverse() {
|
||||
_M_non_dbg_impl.reverse();
|
||||
}
|
||||
void unique() {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
if (__first == __last) return;
|
||||
_Base_iterator __next = __first;
|
||||
while (++__next != __last) {
|
||||
if (*__first == *__next) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __next));
|
||||
_M_non_dbg_impl.erase(__next);
|
||||
}
|
||||
else
|
||||
__first = __next;
|
||||
__next = __first;
|
||||
}
|
||||
}
|
||||
void sort() {
|
||||
_M_non_dbg_impl.sort();
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Predicate>
|
||||
void remove_if(_Predicate __pred) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
while (__first != __last) {
|
||||
_Base_iterator __next = __first;
|
||||
++__next;
|
||||
if (__pred(*__first)) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __first));
|
||||
_M_non_dbg_impl.erase(__first);
|
||||
}
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate>
|
||||
void unique(_BinaryPredicate __binary_pred) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
if (__first == __last) return;
|
||||
_Base_iterator __next = __first;
|
||||
while (++__next != __last) {
|
||||
if (__binary_pred(*__first, *__next)) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __next));
|
||||
_M_non_dbg_impl.erase(__next);
|
||||
}
|
||||
else
|
||||
__first = __next;
|
||||
__next = __first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void merge(_Self& __x, _StrictWeakOrdering __comp) {
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
_STLP_DEBUG_CHECK(_STLP_STD::is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __comp))
|
||||
_STLP_DEBUG_CHECK(_STLP_STD::is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __comp))
|
||||
#endif
|
||||
_M_non_dbg_impl.merge(__x._M_non_dbg_impl, __comp);
|
||||
if (this->get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void sort(_StrictWeakOrdering __comp) {
|
||||
_M_non_dbg_impl.sort(__comp);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_LIST
|
||||
|
||||
#endif /* _STLP_INTERNAL_LIST_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
613
extern/STLport/5.2.1/stlport/stl/debug/_slist.h
vendored
Normal file
613
extern/STLport/5.2.1/stlport/stl/debug/_slist.h
vendored
Normal file
@@ -0,0 +1,613 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_SLIST_H
|
||||
#define _STLP_INTERNAL_DBG_SLIST_H
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
#define _STLP_NON_DBG_SLIST _STLP_PRIV _STLP_NON_DBG_NAME(slist) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
|
||||
{ return (_Tp*)0; }
|
||||
|
||||
template <class _Tp, class _Alloc>
|
||||
inline forward_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_SLIST >&)
|
||||
{ return forward_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
/*
|
||||
* slist special debug traits version.
|
||||
*/
|
||||
template <class _Traits>
|
||||
struct _SlistDbgTraits : _Traits {
|
||||
typedef _SlistDbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
|
||||
typedef _SlistDbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
|
||||
|
||||
/*
|
||||
* We don't want the before_begin iterator to return false at _Dereferenceable
|
||||
* call to do not break the current debug framework but calling * operator should
|
||||
* fail.
|
||||
*/
|
||||
template <class _Iterator>
|
||||
static bool _Check(const _Iterator& __it)
|
||||
{ return !(__it._M_iterator == (__it._Get_container_ptr())->before_begin()); }
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
|
||||
class slist :
|
||||
#if !defined (__DMC__)
|
||||
private
|
||||
#endif
|
||||
_STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
, public __stlport_class<slist<_Tp, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
private:
|
||||
typedef _STLP_NON_DBG_SLIST _Base;
|
||||
typedef slist<_Tp,_Alloc> _Self;
|
||||
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_SLIST > _ConstructCheck;
|
||||
|
||||
public:
|
||||
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Nonconst_traits<value_type> > > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _SlistDbgTraits<_Const_traits<value_type> > > const_iterator;
|
||||
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
private:
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
typedef typename _Base::iterator _Base_iterator;
|
||||
|
||||
public:
|
||||
explicit slist(const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__a) , _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit slist(size_type __n, const value_type& __x = _Tp(),
|
||||
#else
|
||||
slist(size_type __n, const value_type& __x,
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit slist(size_type __n) : _M_non_dbg_impl(__n) , _M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
slist(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#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)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
slist(_InputIterator __first, _InputIterator __last)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# endif
|
||||
#else
|
||||
|
||||
slist(const value_type* __first, const value_type* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first, __last, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
slist(const_iterator __first, const_iterator __last,
|
||||
const allocator_type& __a = allocator_type() )
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif
|
||||
|
||||
slist(const _Self& __x) :
|
||||
_ConstructCheck(__x),
|
||||
_M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
_Self& operator= (const _Self& __x) {
|
||||
if (this != &__x) {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl = __x._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
~slist() {}
|
||||
|
||||
void assign(size_type __n, const value_type& __val) {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.assign(__n, __val);
|
||||
}
|
||||
|
||||
iterator before_begin()
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
|
||||
const_iterator before_begin() const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.before_begin()); }
|
||||
|
||||
iterator begin()
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator begin() const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin());}
|
||||
|
||||
iterator end()
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator end() const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__x._M_non_dbg_impl);
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
reference front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return _M_non_dbg_impl.front();
|
||||
}
|
||||
const_reference front() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return _M_non_dbg_impl.front();
|
||||
}
|
||||
void push_front(const_reference __x) { _M_non_dbg_impl.push_front(__x); }
|
||||
void pop_front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_M_non_dbg_impl.pop_front();
|
||||
}
|
||||
iterator previous(const_iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
|
||||
}
|
||||
const_iterator previous(const_iterator __pos) const {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
return const_iterator(&_M_iter_list, _M_non_dbg_impl.previous(__pos._M_iterator));
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert_after(iterator __pos, const value_type& __x = _Tp()) {
|
||||
#else
|
||||
iterator insert_after(iterator __pos, const value_type& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
return iterator(&_M_iter_list,_M_non_dbg_impl.insert_after(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert_after(iterator __pos) {
|
||||
return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
|
||||
}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
void insert_after(iterator __pos, size_type __n, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_M_non_dbg_impl.insert_after(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#else
|
||||
void assign(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void assign(const value_type *__first, const value_type *__last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.assign(__first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InIter>
|
||||
void insert_after(iterator __pos, _InIter __first, _InIter __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert_after(__pos._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
|
||||
template <class _InIter>
|
||||
void insert(iterator __pos, _InIter __first, _InIter __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#else
|
||||
void insert_after(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert_after(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_after(iterator __pos,
|
||||
const value_type* __first, const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_M_non_dbg_impl.insert_after(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
|
||||
void insert(iterator __pos, const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert(iterator __pos, const value_type* __first,
|
||||
const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert(iterator __pos, const value_type& __x = _Tp()) {
|
||||
#else
|
||||
iterator insert(iterator __pos, const value_type& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert(iterator __pos) {
|
||||
return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
|
||||
}
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
void insert(iterator __pos, size_type __n, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
public:
|
||||
iterator erase_after(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
iterator __tmp = __pos; ++__tmp;
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
|
||||
_Invalidate_iterator(__tmp);
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__pos._M_iterator));
|
||||
}
|
||||
iterator erase_after(iterator __before_first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __last, begin(), end()))
|
||||
iterator __tmp = __before_first; ++__tmp;
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__tmp))
|
||||
_Invalidate_iterators(__tmp, __last);
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase_after(__before_first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_VERBOSE_ASSERT(__pos._M_iterator != _M_non_dbg_impl.before_begin(), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Invalidate_iterator(__pos);
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size, const value_type& __x = _Tp()) {
|
||||
#else
|
||||
void resize(size_type __new_size, const value_type& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
_M_non_dbg_impl.resize(__new_size, __x);
|
||||
}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
void clear() {
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
|
||||
public:
|
||||
// Removes all of the elements from the list __x to *this, inserting
|
||||
// them immediately after __pos. __x must not be *this. Complexity:
|
||||
// linear in __x.size().
|
||||
void splice_after(iterator __pos, _Self& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
|
||||
_M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl);
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
|
||||
// Moves the element that follows __prev to *this, inserting it immediately
|
||||
// after __pos. This is constant time.
|
||||
void splice_after(iterator __pos, _Self& __x, iterator __prev) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__prev))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __prev))
|
||||
iterator __elem = __prev; ++__elem;
|
||||
_M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl, __prev._M_iterator);
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV __change_ite_owner(__elem, &_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterator(__elem);
|
||||
}
|
||||
}
|
||||
|
||||
// Moves the range [__before_first + 1, __before_last + 1) to *this,
|
||||
// inserting it immediately after __pos. This is constant time.
|
||||
void splice_after(iterator __pos, _Self& __x,
|
||||
iterator __before_first, iterator __before_last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__before_first, __before_last))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list, __before_first))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_first))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__before_last))
|
||||
iterator __first = __before_first; ++__first;
|
||||
iterator __last = __before_last; ++__last;
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__first, __last);
|
||||
}
|
||||
_M_non_dbg_impl.splice_after(__pos._M_iterator, __x._M_non_dbg_impl,
|
||||
__before_first._M_iterator, __before_last._M_iterator);
|
||||
}
|
||||
|
||||
void splice(iterator __pos, _Self& __x) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_VERBOSE_ASSERT(!(&__x == this), _StlMsg_INVALID_ARGUMENT)
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl);
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
|
||||
void splice(iterator __pos, _Self& __x, iterator __i) {
|
||||
//__pos should be owned by *this and not be the before_begin iterator
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
//__i should be dereferenceable, not before_begin and be owned by __x
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__i))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&__x._M_iter_list ,__i))
|
||||
_STLP_VERBOSE_ASSERT(!(__i == __x.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV __change_ite_owner(__i, &_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterator(__i);
|
||||
}
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl, __i._M_iterator);
|
||||
}
|
||||
|
||||
void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_VERBOSE_ASSERT(!(__pos._M_iterator == _M_non_dbg_impl.before_begin()), _StlMsg_INVALID_ARGUMENT)
|
||||
//_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, __x.begin(), __x.end()))
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
_STLP_PRIV __change_range_owner(__first, __last, &_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__first, __last);
|
||||
}
|
||||
_M_non_dbg_impl.splice(__pos._M_iterator, __x._M_non_dbg_impl,
|
||||
__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
|
||||
void reverse()
|
||||
{ _M_non_dbg_impl.reverse(); }
|
||||
|
||||
void remove(const value_type& __val) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
while (__first != __last) {
|
||||
_Base_iterator __next = __first;
|
||||
++__next;
|
||||
if (__val == *__first) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __first));
|
||||
_M_non_dbg_impl.erase(__first);
|
||||
}
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
void unique() {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
if (__first == __last) return;
|
||||
_Base_iterator __next = __first;
|
||||
while (++__next != __last) {
|
||||
if (*__first == *__next) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __next));
|
||||
_M_non_dbg_impl.erase(__next);
|
||||
}
|
||||
else
|
||||
__first = __next;
|
||||
__next = __first;
|
||||
}
|
||||
}
|
||||
void merge(_Self& __x) {
|
||||
_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
/* comments below due to bug in GCC compilers: ones eat all memory and die if see
|
||||
* something like namespace_name::func_name() - ptr
|
||||
*/
|
||||
_STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end()))
|
||||
_STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator))
|
||||
#endif
|
||||
_M_non_dbg_impl.merge(__x._M_non_dbg_impl);
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
void sort() {
|
||||
_M_non_dbg_impl.sort();
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _Predicate>
|
||||
void remove_if(_Predicate __pred) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
while (__first != __last) {
|
||||
_Base_iterator __next = __first;
|
||||
++__next;
|
||||
if (__pred(*__first)) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __first));
|
||||
_M_non_dbg_impl.erase(__first);
|
||||
}
|
||||
__first = __next;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _BinaryPredicate>
|
||||
void unique(_BinaryPredicate __pred) {
|
||||
_Base_iterator __first = _M_non_dbg_impl.begin(), __last = _M_non_dbg_impl.end();
|
||||
if (__first == __last) return;
|
||||
_Base_iterator __next = __first;
|
||||
while (++__next != __last) {
|
||||
if (__binary_pred(*__first, *__next)) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __next));
|
||||
_M_non_dbg_impl.erase(__next);
|
||||
}
|
||||
else
|
||||
__first = __next;
|
||||
__next = __first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void merge(_Self& __x, _StrictWeakOrdering __ord) {
|
||||
_STLP_VERBOSE_ASSERT(&__x != this, _StlMsg_INVALID_ARGUMENT)
|
||||
#if !defined (_STLP_NO_EXTENSIONS)
|
||||
/* comments below due to bug in GCC compilers: ones eat all memory and die if see
|
||||
* something like namespace_name::func_name() - ptr
|
||||
*/
|
||||
_STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(_M_non_dbg_impl.begin(), _M_non_dbg_impl.end(), __ord))
|
||||
_STLP_DEBUG_CHECK( /* _STLP_STD:: */ is_sorted(__x.begin()._M_iterator, __x.end()._M_iterator, __ord))
|
||||
#endif
|
||||
_M_non_dbg_impl.merge(__x._M_non_dbg_impl, __ord);
|
||||
if (get_allocator() == __x.get_allocator()) {
|
||||
__x._M_iter_list._Set_owner(_M_iter_list);
|
||||
}
|
||||
else {
|
||||
__x._Invalidate_iterators(__x.begin(), __x.end());
|
||||
}
|
||||
}
|
||||
|
||||
template <class _StrictWeakOrdering>
|
||||
void sort(_StrictWeakOrdering __comp)
|
||||
{ _M_non_dbg_impl.sort(__comp); }
|
||||
#endif
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_SLIST
|
||||
|
||||
#endif /* _STLP_INTERNAL_DBG_SLIST_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
828
extern/STLport/5.2.1/stlport/stl/debug/_string.h
vendored
Normal file
828
extern/STLport/5.2.1/stlport/stl/debug/_string.h
vendored
Normal file
@@ -0,0 +1,828 @@
|
||||
/*
|
||||
* Copyright (c) 1997-1999
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _STLP_DBG_STRING_H
|
||||
#define _STLP_DBG_STRING_H
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#define _STLP_NON_DBG_STRING_NAME _STLP_NON_DBG_NAME(str)
|
||||
#define _STLP_NON_DBG_STRING _STLP_PRIV _STLP_NON_DBG_STRING_NAME <_CharT, _Traits, _Alloc>
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _CharT,class _Traits, class _Alloc>
|
||||
inline _CharT*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
|
||||
{ return (_CharT*)0; }
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
inline random_access_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_STRING >&)
|
||||
{ return random_access_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
class basic_string :
|
||||
#if !defined (__DMC__)
|
||||
private
|
||||
#else
|
||||
public
|
||||
#endif
|
||||
_STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (basic_string)
|
||||
, public __stlport_class<basic_string<_CharT, _Traits, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
protected:
|
||||
typedef _STLP_NON_DBG_STRING _Base;
|
||||
typedef basic_string<_CharT, _Traits, _Alloc> _Self;
|
||||
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_STRING > _ConstructCheck;
|
||||
typedef typename _IsPOD<_CharT>::_Type _Char_Is_POD;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
typedef typename _Base::traits_type traits_type;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > > const_iterator;
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
public: // Constructor, destructor, assignment.
|
||||
typedef typename _Base::_Reserve_t _Reserve_t;
|
||||
|
||||
private:
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
void _Invalidate_all()
|
||||
{ _M_iter_list._Invalidate_all(); }
|
||||
void _Compare_Capacity (size_type __old_capacity) {
|
||||
if (this->capacity() > __old_capacity) {
|
||||
_Invalidate_all();
|
||||
}
|
||||
}
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
|
||||
void _Invalidate_iterators(const iterator& __f, const iterator& __l)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __f, __l); }
|
||||
|
||||
public:
|
||||
#include <stl/_string_npos.h>
|
||||
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
|
||||
explicit basic_string(const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(_Reserve_t __r, size_t __n,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__r, __n, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(const _Self& __s)
|
||||
: _ConstructCheck(__s),
|
||||
_M_non_dbg_impl(__s._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(const _Self& __s, size_type __pos, size_type __n = npos,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__s._M_non_dbg_impl, __pos, __n, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(const _CharT* __s, size_type __n,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__s), _M_non_dbg_impl(__s, __n, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(const _CharT* __s,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__s),
|
||||
_M_non_dbg_impl(__s, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
basic_string(size_type __n, _CharT __c,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __c, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
basic_string(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base >(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
basic_string(const _CharT* __f, const _CharT* __l,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__f, __l),
|
||||
_M_non_dbg_impl(__f, __l, __a), _M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
basic_string(const_iterator __f, const_iterator __l,
|
||||
const allocator_type & __a = allocator_type())
|
||||
: _ConstructCheck(__f, __l),
|
||||
_M_non_dbg_impl(__f._M_iterator, __l._M_iterator, __a), _M_iter_list(&_M_non_dbg_impl) {
|
||||
}
|
||||
#else
|
||||
template <class _InputIterator>
|
||||
basic_string(_InputIterator __f, _InputIterator __l,
|
||||
const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _ConstructCheck(__f, __l),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l), __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
basic_string(_InputIterator __f, _InputIterator __l)
|
||||
: _ConstructCheck(__f, __l),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
private:
|
||||
// constructor from non-debug version for substr
|
||||
basic_string (const _Base& __x)
|
||||
: _M_non_dbg_impl(__x), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
public:
|
||||
_Self& operator=(const _Self& __s) {
|
||||
if (this != &__s) {
|
||||
assign(__s);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& operator=(const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return assign(__s);
|
||||
}
|
||||
|
||||
_Self& operator=(_CharT __c) {
|
||||
return assign(1, __c);
|
||||
}
|
||||
|
||||
// Iterators.
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_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, capacity, etc.
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type length() const { return _M_non_dbg_impl.length(); }
|
||||
size_t max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
|
||||
void resize(size_type __n, _CharT __c) {
|
||||
if (__n > capacity())
|
||||
_Invalidate_all();
|
||||
else if (__n < size())
|
||||
_Invalidate_iterators(begin() + __n, end());
|
||||
_M_non_dbg_impl.resize(__n, __c);
|
||||
}
|
||||
void resize(size_type __n) { resize(__n, _STLP_DEFAULT_CONSTRUCTED(_CharT)); }
|
||||
size_type capacity() const { return _M_non_dbg_impl.capacity(); }
|
||||
|
||||
void reserve(size_type __s = 0) {
|
||||
if (__s > capacity()) _Invalidate_all();
|
||||
_M_non_dbg_impl.reserve(__s);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
|
||||
const_reference operator[](size_type __n) const {
|
||||
_STLP_VERBOSE_ASSERT(__n <= this->size(), _StlMsg_OUT_OF_BOUNDS);
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
|
||||
reference operator[](size_type __n) {
|
||||
_STLP_VERBOSE_ASSERT(__n < this->size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
|
||||
const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
|
||||
reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
|
||||
|
||||
// Append, operator+=, push_back.
|
||||
_Self& operator+=(const _Self& __s) { return append(__s); }
|
||||
_Self& operator+=(const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return append(__s);
|
||||
}
|
||||
_Self& operator+=(_CharT __c) { return append(1, __c); }
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIter>
|
||||
_Self& append(_InputIter __first, _InputIter __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || \
|
||||
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
|
||||
_Self& append(const _CharT* __f, const _CharT* __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__f, __l);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__f._M_iterator, __l._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
_Self& append(const _Self& __s) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__s._M_non_dbg_impl);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const _Self& __s, size_type __pos, size_type __n) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__s._M_non_dbg_impl, __pos, __n);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__s, __n);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.append(__s);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& append(size_type __n, _CharT __c) {
|
||||
size_type __old_capacity = this->capacity();
|
||||
_M_non_dbg_impl.append(__n, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
void push_back(_CharT __c) {
|
||||
size_type __old_capacity = this->capacity();
|
||||
_M_non_dbg_impl.push_back(__c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
_Invalidate_iterator(this->end());
|
||||
_M_non_dbg_impl.pop_back();
|
||||
}
|
||||
|
||||
// Assign
|
||||
_Self& assign(const _Self& __s) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__s._M_non_dbg_impl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(const _Self& __s, size_type __pos, size_type __n) {
|
||||
if (__pos < __s.size()) {
|
||||
_Invalidate_all();
|
||||
}
|
||||
_M_non_dbg_impl.assign(__s._M_non_dbg_impl, __pos, __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__s, __s + __n);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& assign(size_type __n, _CharT __c) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__n, __c);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIter>
|
||||
inline _Self& assign(_InputIter __first, _InputIter __last) {
|
||||
_STLP_FIX_LITERAL_BUG(__first) _STLP_FIX_LITERAL_BUG(__last)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || \
|
||||
!defined (_STLP_NO_METHOD_SPECIALIZATION) && !defined (_STLP_NO_EXTENSIONS)
|
||||
_Self& assign(const _CharT* __f, const _CharT* __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f) _STLP_FIX_LITERAL_BUG(__l)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__f, __l);
|
||||
return *this;
|
||||
}
|
||||
_Self& assign(const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__f._M_iterator, __l._M_iterator);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Insert
|
||||
_Self& insert(size_type __pos, const _Self& __s) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _Self& __s,
|
||||
size_type __beg, size_type __n) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos, __s._M_non_dbg_impl, __beg, __n);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos, __s, __n);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return insert(__pos, __s, _Traits::length(__s));
|
||||
}
|
||||
|
||||
_Self& insert(size_type __pos, size_type __n, _CharT __c) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos, __n, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
iterator insert(iterator __p, _CharT __c) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
size_type __old_capacity = capacity();
|
||||
typename _Base::iterator __ret = _M_non_dbg_impl.insert(__p._M_iterator, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return iterator(&_M_iter_list, __ret);
|
||||
}
|
||||
|
||||
void insert(iterator __p, size_t __n, _CharT __c) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__p._M_iterator, __n, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIter>
|
||||
void insert(iterator __p, _InputIter __first, _InputIter __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
|
||||
|
||||
size_type __old_capacity = this->capacity();
|
||||
_M_non_dbg_impl.insert(__p._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
void insert(iterator __p, const _CharT* __f, const _CharT* __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f,__l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__p._M_iterator, __f, __l);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
// Those overloads are necessary to check self referencing correctly in non debug
|
||||
// basic_string implementation
|
||||
void insert(iterator __p, const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
|
||||
# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
_STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __f))
|
||||
# endif
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
void insert(iterator __p, iterator __f, iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__p))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f,__l))
|
||||
# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
_STLP_STD_DEBUG_CHECK(__check_if_not_owner(&_M_iter_list, __f))
|
||||
# endif
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__p._M_iterator, __f._M_iterator, __l._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Erase.
|
||||
_Self& erase(size_type __pos = 0, size_type __n = npos) {
|
||||
if (__pos < size()) {
|
||||
_Invalidate_iterators(begin() + __pos, end());
|
||||
}
|
||||
_M_non_dbg_impl.erase(__pos, __n);
|
||||
return *this;
|
||||
}
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list,__pos))
|
||||
_Invalidate_iterators(__pos, end());
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __f, iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
|
||||
_Invalidate_iterators(__f, end());
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__f._M_iterator, __l._M_iterator));
|
||||
}
|
||||
|
||||
// Substring.
|
||||
_Self substr(size_type __pos = 0, size_type __n = npos) const
|
||||
{ return _M_non_dbg_impl.substr(__pos, __n); }
|
||||
|
||||
// Replace. (Conceptually equivalent to erase followed by insert.)
|
||||
_Self& replace(size_type __pos, size_type __n, const _Self& __s) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__pos, __n, __s._M_non_dbg_impl);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos1, size_type __n1, const _Self& __s,
|
||||
size_type __pos2, size_type __n2) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__pos, __n1, __s, __n2);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1, const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__pos, __n1, __s);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c) {
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__pos, __n1, __n2, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __f, iterator __l, const _Self& __s) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s._M_non_dbg_impl);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __f, iterator __l, const _CharT* __s, size_type __n) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s, __n);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __f, iterator __l, const _CharT* __s) {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __s);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
_Self& replace(iterator __f, iterator __l, size_type __n, _CharT __c) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l, begin(), end()))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__f._M_iterator, __l._M_iterator, __n, __c);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIter>
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
_InputIter __f, _InputIter __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__f), _STLP_PRIV _Non_Dbg_iter(__l));
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const _CharT* __f, const _CharT* __l) {
|
||||
_STLP_FIX_LITERAL_BUG(__f)_STLP_FIX_LITERAL_BUG(__l)
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__f, __l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator, __f, __l);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
const_iterator __f, const_iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
|
||||
__f._M_iterator, __l._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
_Self& replace(iterator __first, iterator __last,
|
||||
iterator __f, iterator __l) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__f, __l))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.replace(__first._M_iterator, __last._M_iterator,
|
||||
__f._M_iterator, __l._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Other modifier member functions.
|
||||
void swap(_Self& __s) {
|
||||
_M_iter_list._Swap_owners(__s._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__s._M_non_dbg_impl);
|
||||
}
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
|
||||
void _M_swap_workaround(_Self& __x) { swap(__x); }
|
||||
#endif
|
||||
|
||||
int compare(const _Self& __s) const
|
||||
{ return _M_non_dbg_impl.compare(__s._M_non_dbg_impl); }
|
||||
int compare(size_type __pos, size_type __n, const _Self& __s) const
|
||||
{ return _M_non_dbg_impl.compare(__pos, __n, __s._M_non_dbg_impl); }
|
||||
int compare(size_type __pos1, size_type __n1, const _Self& __s,
|
||||
size_type __pos2, size_type __n2) const
|
||||
{ return _M_non_dbg_impl.compare(__pos1, __n1, __s._M_non_dbg_impl, __pos2, __n2); }
|
||||
int compare(const _CharT* __s) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return _M_non_dbg_impl.compare(__s);
|
||||
}
|
||||
int compare(size_type __pos, size_type __n, const _CharT* __s) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return _M_non_dbg_impl.compare(__pos, __n, __s);
|
||||
}
|
||||
int compare(size_type __pos1, size_type __n1, const _CharT* __s,
|
||||
size_type __n2) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
return _M_non_dbg_impl.compare(__pos1, __n1, __s, __n2);
|
||||
}
|
||||
|
||||
// Helper functions for compare.
|
||||
static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
|
||||
const _CharT* __f2, const _CharT* __l2)
|
||||
{ return _Base::_M_compare(__f1, __l1, __f2, __l2); }
|
||||
static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
|
||||
const _CharT* __f2, const _CharT* __l2)
|
||||
{ return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2, __l2); }
|
||||
static int _STLP_CALL _M_compare(const _CharT* __f1, const _CharT* __l1,
|
||||
const_iterator __f2, const_iterator __l2)
|
||||
{ return _Base::_M_compare(__f1, __l1, __f2._M_iterator, __l2._M_iterator); }
|
||||
static int _STLP_CALL _M_compare(const_iterator __f1, const_iterator __l1,
|
||||
const_iterator __f2, const_iterator __l2)
|
||||
{ return _Base::_M_compare(__f1._M_iterator, __l1._M_iterator, __f2._M_iterator, __l2._M_iterator); }
|
||||
|
||||
const _CharT* c_str() const { return _M_non_dbg_impl.c_str(); }
|
||||
const _CharT* data() const { return _M_non_dbg_impl.data(); }
|
||||
|
||||
size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.copy(__s, __n, __pos); }
|
||||
|
||||
// find.
|
||||
size_type find(const _Self& __s, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.find(__s._M_non_dbg_impl, __pos); }
|
||||
size_type find(const _CharT* __s, size_type __pos = 0) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find(__s, __pos);
|
||||
}
|
||||
size_type find(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find(__s, __pos, __n);
|
||||
}
|
||||
// WIE: Versant schema compiler 5.2.2 ICE workaround
|
||||
size_type find(_CharT __c) const { return find(__c, 0); }
|
||||
size_type find(_CharT __c, size_type __pos /* = 0 */) const
|
||||
{ return _M_non_dbg_impl.find(__c, __pos); }
|
||||
|
||||
// rfind.
|
||||
size_type rfind(const _Self& __s, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.rfind(__s._M_non_dbg_impl, __pos); }
|
||||
size_type rfind(const _CharT* __s, size_type __pos = npos) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.rfind(__s, __pos);
|
||||
}
|
||||
size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.rfind(__s, __pos, __n);
|
||||
}
|
||||
size_type rfind(_CharT __c, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.rfind(__c, __pos); }
|
||||
|
||||
// find_first_of
|
||||
size_type find_first_of(const _Self& __s, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.find_first_of(__s._M_non_dbg_impl, __pos); }
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos = 0) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_first_of(__s, __pos);
|
||||
}
|
||||
size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_first_of(__s, __pos, __n);
|
||||
}
|
||||
size_type find_first_of(_CharT __c, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.find_first_of(__c, __pos); }
|
||||
|
||||
// find_last_of
|
||||
size_type find_last_of(const _Self& __s, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.find_last_of(__s._M_non_dbg_impl, __pos); }
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos = npos) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_last_of(__s, __pos);
|
||||
}
|
||||
size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_last_of(__s, __pos, __n);
|
||||
}
|
||||
size_type find_last_of(_CharT __c, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.rfind(__c, __pos); }
|
||||
|
||||
// find_first_not_of
|
||||
size_type find_first_not_of(const _Self& __s, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.find_first_not_of(__s._M_non_dbg_impl, __pos); }
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_first_not_of(__s, __pos);
|
||||
}
|
||||
size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_first_not_of(__s, __pos, __n);
|
||||
}
|
||||
size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
|
||||
{ return _M_non_dbg_impl.find_first_not_of(__c, __pos); }
|
||||
|
||||
// find_last_not_of
|
||||
size_type find_last_not_of(const _Self& __s, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.find_last_not_of(__s._M_non_dbg_impl, __pos); }
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos = npos) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_last_not_of(__s, __pos);
|
||||
}
|
||||
size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const {
|
||||
_STLP_FIX_LITERAL_BUG(__s)
|
||||
_STLP_VERBOSE_ASSERT((__s != 0), _StlMsg_INVALID_ARGUMENT)
|
||||
return _M_non_dbg_impl.find_last_not_of(__s, __pos, __n);
|
||||
}
|
||||
size_type find_last_not_of(_CharT __c, size_type __pos = npos) const
|
||||
{ return _M_non_dbg_impl.find_last_not_of(__c, __pos); }
|
||||
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPRESSION)
|
||||
# include <stl/debug/_string_sum_methods.h>
|
||||
#endif
|
||||
};
|
||||
|
||||
// This is a hook to instantiate STLport exports in a designated DLL
|
||||
#if defined (_STLP_USE_TEMPLATE_EXPORT) && !defined (_STLP_USE_MSVC6_MEM_T_BUG_WORKAROUND)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <char, char_traits<char>, allocator<char> > >;
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_string<char, char_traits<char>, allocator<char> >;
|
||||
# if defined (_STLP_HAS_WCHAR_T)
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
_STLP_EXPORT_TEMPLATE_CLASS __construct_checker<_STLP_NON_DBG_STRING_NAME <wchar_t, char_traits<wchar_t>, allocator<wchar_t> > >;
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_EXPORT_TEMPLATE_CLASS basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#undef _STLP_NON_DBG_STRING
|
||||
#undef _STLP_NON_DBG_STRING_NAME
|
||||
|
||||
#if defined (__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ == 96)
|
||||
template <class _CharT, class _Traits, class _Alloc>
|
||||
const size_t basic_string<_CharT, _Traits, _Alloc>::npos = ~(size_t) 0;
|
||||
#endif
|
||||
|
||||
#if defined (basic_string)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
#undef basic_string
|
||||
#endif
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#endif /* _STLP_DBG_STRING */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
111
extern/STLport/5.2.1/stlport/stl/debug/_string_sum_methods.h
vendored
Normal file
111
extern/STLport/5.2.1/stlport/stl/debug/_string_sum_methods.h
vendored
Normal file
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* All the necessary methods used for template expressions with basic_string
|
||||
* This file do not have to be macro guarded as it is only used in the _string.h
|
||||
* file and it is a part of the basic_string definition.
|
||||
*/
|
||||
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s)
|
||||
: _M_non_dbg_impl(_Reserve_t(), __s.size(), __s.get_allocator()),
|
||||
_M_iter_list(&_M_non_dbg_impl)
|
||||
{ _M_append_sum(__s, _M_non_dbg_impl); }
|
||||
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
basic_string(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s,
|
||||
size_type __pos, size_type __n = npos,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(_Reserve_t(), (__pos <= __s.size()) ? ((min) (__n, __s.size() - __pos)) : 0, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
size_type __size = __s.size();
|
||||
if (__pos > __size)
|
||||
//This call will generate the necessary out of range exception:
|
||||
_M_non_dbg_impl.at(0);
|
||||
else
|
||||
_M_append_sum_pos(__s, __pos, (min) (__n, __size - __pos), _M_non_dbg_impl);
|
||||
}
|
||||
|
||||
private:
|
||||
_Base& _M_append_fast(_STLP_PRIV __char_wrapper<_CharT> __c, _Base &__str)
|
||||
{ return __str += __c.getValue(); }
|
||||
_Base& _M_append_fast(_CharT const* __s, size_type __s_size, _Base &__str)
|
||||
{ return __str.append(__s, __s_size); }
|
||||
_Base& _M_append_fast(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _Base &__str)
|
||||
{ return _M_append_fast(__s.c_str(), __s.size(), __str); }
|
||||
_Base& _M_append_fast(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _Base &__str)
|
||||
{ return _M_append_fast(__s.b_str(), __str); }
|
||||
_Base& _M_append_fast(_Self const& __s, _Base &__str)
|
||||
{ return _M_append_fast(__s.data(), __s.size(), __str); }
|
||||
_Base& _M_append_fast(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _Base &__str)
|
||||
{ return __str; }
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
_Base& _M_append_fast(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s, _Base &__str)
|
||||
{ return _M_append_fast(__s.getRhs(), _M_append_fast(__s.getLhs(), __str)); }
|
||||
|
||||
_Base& _M_append_fast_pos(_STLP_PRIV __char_wrapper<_CharT> __c, _Base &__str, size_type /*__pos*/, size_type __n) {
|
||||
if (__n == 0)
|
||||
return __str;
|
||||
return __str += __c.getValue();
|
||||
}
|
||||
_Base& _M_append_fast_pos(_CharT const* __s, size_type __s_size, _Base &__str,
|
||||
size_type __pos, size_type __n)
|
||||
{ return __str.append(__s + __pos, __s + __pos + (min)(__n, __s_size - __pos)); }
|
||||
_Base& _M_append_fast_pos(_STLP_PRIV __cstr_wrapper<_CharT> const& __s, _Base &__str,
|
||||
size_type __pos, size_type __n)
|
||||
{ return _M_append_fast_pos(__s.c_str(), __s.size(), __str, __pos, __n); }
|
||||
_Base& _M_append_fast_pos(_STLP_PRIV __bstr_wrapper<_CharT, _Traits, _Alloc> __s, _Base &__str,
|
||||
size_type __pos, size_type __n)
|
||||
{ return _M_append_fast_pos(__s.b_str(), __str, __pos, __n); }
|
||||
_Base& _M_append_fast_pos(_Self const& __s, _Base &__str, size_type __pos, size_type __n)
|
||||
{ return _M_append_fast_pos(__s.data(), __s.size(), __str, __pos, __n); }
|
||||
_Base& _M_append_fast_pos(_STLP_PRIV __sum_storage_elem<_CharT, _Traits, _Alloc> const&, _Base &__str,
|
||||
size_type /*__pos*/, size_type /*__n*/)
|
||||
{ return __str; }
|
||||
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
_Base& _M_append_fast_pos(_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s,
|
||||
_Base &__str, size_type __pos, size_type __n) {
|
||||
if (__n == 0) {
|
||||
return __str;
|
||||
}
|
||||
size_type __lhs_size = __s.getLhs().size();
|
||||
if (__pos < __lhs_size) {
|
||||
if (__n < (__lhs_size - __pos)) {
|
||||
return _M_append_fast_pos(__s.getLhs(), __str, __pos, __n);
|
||||
} else {
|
||||
return _M_append_fast_pos(__s.getRhs(), _M_append_fast_pos(__s.getLhs(), __str, __pos, __n),
|
||||
0, __n - (__lhs_size - __pos));
|
||||
}
|
||||
} else {
|
||||
return _M_append_fast_pos(__s.getRhs(), __str, __pos - __lhs_size, __n);
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
_Self& _M_append_sum (_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s,
|
||||
_Base &__impl) {
|
||||
_M_append_fast(__s, __impl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <class _Left, class _Right, class _StorageDir>
|
||||
_Self& _M_append_sum_pos (_STLP_PRIV __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir> const& __s,
|
||||
size_type __pos, size_type __n, _Base &__impl) {
|
||||
_M_non_dbg_impl.reserve(_M_non_dbg_impl.size() + (min) (__s.size() - __pos, __n));
|
||||
_M_append_fast_pos(__s, __impl, __pos, __n);
|
||||
return *this;
|
||||
}
|
||||
317
extern/STLport/5.2.1/stlport/stl/debug/_tree.h
vendored
Normal file
317
extern/STLport/5.2.1/stlport/stl/debug/_tree.h
vendored
Normal file
@@ -0,0 +1,317 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_TREE_H
|
||||
#define _STLP_INTERNAL_DBG_TREE_H
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
|
||||
# include <stl/_function_base.h>
|
||||
#endif
|
||||
|
||||
#ifndef _STLP_INTERNAL_ALLOC_H
|
||||
# include <stl/_alloc.h>
|
||||
#endif
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Key, class _Compare>
|
||||
class _DbgCompare {
|
||||
public:
|
||||
_DbgCompare() {}
|
||||
_DbgCompare(const _Compare& __cmp) : _M_non_dbg_cmp(__cmp) {}
|
||||
_DbgCompare(const _DbgCompare& __cmp) : _M_non_dbg_cmp(__cmp._M_non_dbg_cmp) {}
|
||||
|
||||
#if !defined (_STLP_USE_CONTAINERS_EXTENSION)
|
||||
bool operator () (const _Key& __lhs, const _Key& __rhs) const {
|
||||
#else
|
||||
template <class _Kp1, class _Kp2>
|
||||
bool operator () (const _Kp1& __lhs, const _Kp2& __rhs) const {
|
||||
#endif
|
||||
if (_M_non_dbg_cmp(__lhs, __rhs)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_Compare non_dbg_key_comp() const { return _M_non_dbg_cmp; }
|
||||
private:
|
||||
_Compare _M_non_dbg_cmp;
|
||||
};
|
||||
|
||||
#define _STLP_NON_DBG_TREE _STLP_PRIV _STLP_NON_DBG_NAME(Rb_tree) <_Key, _STLP_PRIV _DbgCompare<_Key, _Compare>, _Value, _KeyOfValue, _Traits, _Alloc>
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
template <class _Key, class _Compare,
|
||||
class _Value, class _KeyOfValue, class _Traits, class _Alloc >
|
||||
inline _Value*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&)
|
||||
{ return (_Value*)0; }
|
||||
template <class _Key, class _Compare,
|
||||
class _Value, class _KeyOfValue, class _Traits, class _Alloc >
|
||||
inline bidirectional_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_TREE >&)
|
||||
{ return bidirectional_iterator_tag(); }
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
#endif
|
||||
|
||||
template <class _Key, class _Compare,
|
||||
class _Value, class _KeyOfValue, class _Traits,
|
||||
_STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Value>) >
|
||||
class _Rb_tree {
|
||||
typedef _STLP_NON_DBG_TREE _Base;
|
||||
typedef _Rb_tree<_Key, _Compare, _Value, _KeyOfValue, _Traits, _Alloc> _Self;
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
typedef typename _Base::key_type key_type;
|
||||
|
||||
typedef typename _Traits::_NonConstTraits _NonConstIteTraits;
|
||||
typedef typename _Traits::_ConstTraits _ConstIteTraits;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_NonConstIteTraits> > iterator;
|
||||
typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_ConstIteTraits> > const_iterator;
|
||||
|
||||
_STLP_DECLARE_BIDIRECTIONAL_REVERSE_ITERATORS;
|
||||
|
||||
private:
|
||||
_STLP_KEY_TYPE_FOR_CONT_EXT(key_type)
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); }
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
typedef typename _Base::iterator _Base_iterator;
|
||||
typedef typename _Base::const_iterator _Base_const_iterator;
|
||||
|
||||
public:
|
||||
_Rb_tree()
|
||||
: _M_non_dbg_impl(), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
_Rb_tree(const _Compare& __comp)
|
||||
: _M_non_dbg_impl(__comp), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
_Rb_tree(const _Compare& __comp, const allocator_type& __a)
|
||||
: _M_non_dbg_impl(__comp, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
_Rb_tree(const _Self& __x)
|
||||
: _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
_Rb_tree(__move_source<_Self> src):
|
||||
_M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
~_Rb_tree() {}
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
if (this != &__x) {
|
||||
//Should not invalidate end iterator:
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl = __x._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
_Compare key_comp() const { return _M_non_dbg_impl.key_comp().non_dbg_key_comp(); }
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_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()); }
|
||||
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
size_type size() const { return _M_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
size_type count(const _KT& __x) const { return _M_non_dbg_impl.count(__x); }
|
||||
|
||||
void swap(_Self& __t) {
|
||||
_M_non_dbg_impl.swap(__t._M_non_dbg_impl);
|
||||
_M_iter_list._Swap_owners(__t._M_iter_list);
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator find(const _KT& __k)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator find(const _KT& __k) const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.find(__k)); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator lower_bound(const _KT& __x)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator lower_bound(const _KT& __x) const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
iterator upper_bound(const _KT& __x)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); }
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
const_iterator upper_bound(const _KT& __x) const
|
||||
{ return const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)); }
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator,iterator> equal_range(const _KT& __x) {
|
||||
return pair<iterator, iterator>(iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)),
|
||||
iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)));
|
||||
}
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range(const _KT& __x) const {
|
||||
return pair<const_iterator,const_iterator>(const_iterator(&_M_iter_list, _M_non_dbg_impl.lower_bound(__x)),
|
||||
const_iterator(&_M_iter_list, _M_non_dbg_impl.upper_bound(__x)));
|
||||
}
|
||||
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<iterator,iterator> equal_range_unique(const _KT& __x) {
|
||||
_STLP_STD::pair<_Base_iterator, _Base_iterator> __p;
|
||||
__p = _M_non_dbg_impl.equal_range_unique(__x);
|
||||
return pair<iterator, iterator>(iterator(&_M_iter_list, __p.first), iterator(&_M_iter_list, __p.second));
|
||||
}
|
||||
_STLP_TEMPLATE_FOR_CONT_EXT
|
||||
pair<const_iterator, const_iterator> equal_range_unique(const _KT& __x) const {
|
||||
_STLP_STD::pair<_Base_const_iterator, _Base_const_iterator> __p;
|
||||
__p = _M_non_dbg_impl.equal_range_unique(__x);
|
||||
return pair<const_iterator, const_iterator>(const_iterator(&_M_iter_list, __p.first),
|
||||
const_iterator(&_M_iter_list, __p.second));
|
||||
}
|
||||
|
||||
pair<iterator,bool> insert_unique(const value_type& __x) {
|
||||
_STLP_STD::pair<_Base_iterator, bool> __res = _M_non_dbg_impl.insert_unique(__x);
|
||||
return pair<iterator, bool>(iterator(&_M_iter_list, __res.first), __res.second);
|
||||
}
|
||||
iterator insert_equal(const value_type& __x)
|
||||
{ return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__x)); }
|
||||
|
||||
iterator insert_unique(iterator __pos, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert_unique(__pos._M_iterator, __x));
|
||||
}
|
||||
iterator insert_equal(iterator __pos, const value_type& __x) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list, __pos))
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert_equal(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template<class _InputIterator>
|
||||
void insert_equal(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_equal(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
template<class _InputIterator>
|
||||
void insert_unique(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_unique(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#else
|
||||
void insert_unique(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_unique(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_unique(const value_type* __first, const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(__check_ptr_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_unique(__first, __last);
|
||||
}
|
||||
void insert_equal(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_equal(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void insert_equal(const value_type* __first, const value_type* __last) {
|
||||
_STLP_DEBUG_CHECK(__check_ptr_range(__first,__last))
|
||||
_M_non_dbg_impl.insert_equal(__first, __last);
|
||||
}
|
||||
#endif
|
||||
|
||||
void erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(__check_if_owner(&_M_iter_list,__pos))
|
||||
_STLP_DEBUG_CHECK(_Dereferenceable(__pos))
|
||||
_Invalidate_iterator(__pos);
|
||||
_M_non_dbg_impl.erase(__pos._M_iterator);
|
||||
}
|
||||
size_type erase(const key_type& __x) {
|
||||
pair<iterator, iterator> __p = equal_range(__x);
|
||||
size_type __n = _STLP_STD::distance(__p.first._M_iterator, __p.second._M_iterator);
|
||||
_Invalidate_iterators(__p.first, __p.second);
|
||||
_M_non_dbg_impl.erase(__p.first._M_iterator, __p.second._M_iterator);
|
||||
return __n;
|
||||
}
|
||||
size_type erase_unique(const key_type& __x) {
|
||||
_Base_iterator __i = _M_non_dbg_impl.find(__x);
|
||||
if (__i != _M_non_dbg_impl.end()) {
|
||||
_Invalidate_iterator(iterator(&_M_iter_list, __i));
|
||||
_M_non_dbg_impl.erase(__i);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(__check_range(__first, __last, begin(), end()))
|
||||
_Invalidate_iterators(__first, __last);
|
||||
_M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
void erase(const key_type* __first, const key_type* __last) {
|
||||
while (__first != __last) erase(*__first++);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
//should not invalidate end:
|
||||
_Invalidate_iterators(begin(), end());
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_TREE
|
||||
|
||||
#endif /* _STLP_INTERNAL_DBG_TREE_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
425
extern/STLport/5.2.1/stlport/stl/debug/_vector.h
vendored
Normal file
425
extern/STLport/5.2.1/stlport/stl/debug/_vector.h
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (c) 1994
|
||||
* Hewlett-Packard Company
|
||||
*
|
||||
* Copyright (c) 1996,1997
|
||||
* Silicon Graphics Computer Systems, Inc.
|
||||
*
|
||||
* Copyright (c) 1997
|
||||
* Moscow Center for SPARC Technology
|
||||
*
|
||||
* Copyright (c) 1999
|
||||
* Boris Fomitchev
|
||||
*
|
||||
* 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_INTERNAL_DBG_VECTOR_H
|
||||
#define _STLP_INTERNAL_DBG_VECTOR_H
|
||||
|
||||
#ifndef _STLP_DBG_ITERATOR_H
|
||||
# include <stl/debug/_iterator.h>
|
||||
#endif
|
||||
|
||||
#define _STLP_NON_DBG_VECTOR _STLP_PRIV _STLP_NON_DBG_NAME(vector) <_Tp, _Alloc>
|
||||
|
||||
_STLP_BEGIN_NAMESPACE
|
||||
|
||||
#if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
|
||||
template <class _Tp, class _Alloc>
|
||||
inline _Tp*
|
||||
value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_VECTOR >&)
|
||||
{ return (_Tp*)0; }
|
||||
template <class _Tp, class _Alloc>
|
||||
inline random_access_iterator_tag
|
||||
iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_VECTOR >&)
|
||||
{ return random_access_iterator_tag(); }
|
||||
#endif
|
||||
|
||||
_STLP_MOVE_TO_PRIV_NAMESPACE
|
||||
|
||||
template <class _Tp, class _NcIt>
|
||||
struct _Vector_const_traits;
|
||||
|
||||
template <class _Tp, class _NcIt>
|
||||
struct _Vector_nonconst_traits {
|
||||
typedef _Nonconst_traits<_Tp> _BaseT;
|
||||
typedef _Tp value_type;
|
||||
typedef _Tp& reference;
|
||||
typedef _Tp* pointer;
|
||||
typedef _Vector_const_traits<_Tp, _NcIt> _ConstTraits;
|
||||
typedef _Vector_nonconst_traits<_Tp, _NcIt> _NonConstTraits;
|
||||
};
|
||||
|
||||
template <class _Tp, class _NcIt>
|
||||
struct _Vector_const_traits {
|
||||
typedef _Const_traits<_Tp> _BaseT;
|
||||
typedef _Tp value_type;
|
||||
typedef const _Tp& reference;
|
||||
typedef const _Tp* pointer;
|
||||
typedef _Vector_const_traits<_Tp, _NcIt> _ConstTraits;
|
||||
typedef _Vector_nonconst_traits<_Tp, _NcIt> _NonConstTraits;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Vector_nonconst_traits<bool, _Bit_iterator> {
|
||||
typedef _Bit_iterator::value_type value_type;
|
||||
typedef _Bit_iterator::reference reference;
|
||||
typedef _Bit_iterator::pointer pointer;
|
||||
typedef _Vector_const_traits<bool, _Bit_iterator> _ConstTraits;
|
||||
typedef _Vector_nonconst_traits<bool, _Bit_iterator> _NonConstTraits;
|
||||
};
|
||||
|
||||
_STLP_TEMPLATE_NULL
|
||||
struct _Vector_const_traits<bool, _Bit_iterator> {
|
||||
typedef _Bit_const_iterator::value_type value_type;
|
||||
typedef _Bit_const_iterator::reference reference;
|
||||
typedef _Bit_const_iterator::pointer pointer;
|
||||
typedef _Vector_const_traits<bool, _Bit_iterator> _ConstTraits;
|
||||
typedef _Vector_nonconst_traits<bool, _Bit_iterator> _NonConstTraits;
|
||||
};
|
||||
|
||||
_STLP_MOVE_TO_STD_NAMESPACE
|
||||
|
||||
template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
|
||||
class vector :
|
||||
#if !defined (__DMC__)
|
||||
private
|
||||
#endif
|
||||
_STLP_PRIV __construct_checker< _STLP_NON_DBG_VECTOR >
|
||||
#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
|
||||
, public __stlport_class<vector<_Tp, _Alloc> >
|
||||
#endif
|
||||
{
|
||||
private:
|
||||
typedef _STLP_NON_DBG_VECTOR _Base;
|
||||
typedef vector<_Tp, _Alloc> _Self;
|
||||
typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_VECTOR > _ConstructCheck;
|
||||
_Base _M_non_dbg_impl;
|
||||
_STLP_PRIV __owned_list _M_iter_list;
|
||||
|
||||
public:
|
||||
__IMPORT_CONTAINER_TYPEDEFS(_Base)
|
||||
|
||||
typedef _STLP_PRIV _DBG_iter<_Base,
|
||||
_STLP_PRIV _DbgTraits<_STLP_PRIV _Vector_nonconst_traits<value_type, typename _Base::iterator> > > iterator;
|
||||
|
||||
typedef _STLP_PRIV _DBG_iter<_Base,
|
||||
_STLP_PRIV _DbgTraits<_STLP_PRIV _Vector_const_traits<value_type, typename _Base::iterator> > > const_iterator;
|
||||
|
||||
private:
|
||||
void _Invalidate_all()
|
||||
{ _M_iter_list._Invalidate_all(); }
|
||||
void _Invalidate_iterator(const iterator& __it)
|
||||
{ _STLP_PRIV __invalidate_iterator(&_M_iter_list, __it); }
|
||||
void _Invalidate_iterators(const iterator& __first, const iterator& __last)
|
||||
{ _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
|
||||
|
||||
void _Check_Overflow(size_type __nb) {
|
||||
if (size() + __nb > capacity())
|
||||
_Invalidate_all();
|
||||
}
|
||||
void _Compare_Capacity (size_type __old_capacity) {
|
||||
if (capacity() > __old_capacity) {
|
||||
_Invalidate_all();
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
_STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
|
||||
|
||||
allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
|
||||
|
||||
iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
|
||||
iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
|
||||
const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_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_non_dbg_impl.size(); }
|
||||
size_type max_size() const { return _M_non_dbg_impl.max_size(); }
|
||||
size_type capacity() const { return _M_non_dbg_impl.capacity(); }
|
||||
bool empty() const { return _M_non_dbg_impl.empty(); }
|
||||
|
||||
reference operator[](size_type __n) {
|
||||
_STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
|
||||
const_reference operator[](size_type __n) const {
|
||||
_STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
|
||||
return _M_non_dbg_impl[__n];
|
||||
}
|
||||
|
||||
reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
|
||||
const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
|
||||
|
||||
explicit vector(const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit vector(size_type __n, const _Tp& __x = _Tp(),
|
||||
#else
|
||||
vector(size_type __n, const _Tp& __x,
|
||||
#endif
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
explicit vector(size_type __n)
|
||||
: _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif
|
||||
|
||||
vector(const _Self& __x)
|
||||
: _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl), _M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
#if !defined (_STLP_NO_MOVE_SEMANTIC)
|
||||
vector(__move_source<_Self> src)
|
||||
: _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {
|
||||
# if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
|
||||
src.get()._M_iter_list._Invalidate_all();
|
||||
# else
|
||||
src.get()._M_iter_list._Set_owner(_M_iter_list);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
vector(_InputIterator __first, _InputIterator __last,
|
||||
const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
|
||||
template <class _InputIterator>
|
||||
vector(_InputIterator __first, _InputIterator __last)
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
# endif
|
||||
#else
|
||||
vector(const _Tp* __first, const _Tp* __last,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last), _M_non_dbg_impl(__first, __last, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
|
||||
// mysterious VC++ bug ?
|
||||
vector(const_iterator __first, const_iterator __last ,
|
||||
const allocator_type& __a = allocator_type())
|
||||
: _ConstructCheck(__first, __last),
|
||||
_M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
|
||||
_M_iter_list(&_M_non_dbg_impl) {}
|
||||
#endif /* _STLP_MEMBER_TEMPLATES */
|
||||
|
||||
_Self& operator=(const _Self& __x) {
|
||||
if (this != &__x) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl = __x._M_non_dbg_impl;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void reserve(size_type __n) {
|
||||
if (capacity() < __n)
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.reserve(__n);
|
||||
}
|
||||
|
||||
reference front() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
const_reference front() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *begin();
|
||||
}
|
||||
reference back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
const_reference back() const {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
return *(--end());
|
||||
}
|
||||
|
||||
void swap(_Self& __x) {
|
||||
_M_iter_list._Swap_owners(__x._M_iter_list);
|
||||
_M_non_dbg_impl.swap(__x._M_non_dbg_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_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert(iterator __pos, const _Tp& __x = _Tp()) {
|
||||
#else
|
||||
iterator insert(iterator __pos, const _Tp& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Check_Overflow(1);
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
|
||||
}
|
||||
|
||||
#if defined(_STLP_DONT_SUP_DFLT_PARAM)
|
||||
iterator insert(iterator __pos)
|
||||
{ return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
// Check whether it's an integral type. If so, it's not an iterator.
|
||||
template <class _InputIterator>
|
||||
void insert(iterator __pos,
|
||||
_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator,
|
||||
_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES)
|
||||
void insert (iterator __pos,
|
||||
const value_type *__first, const value_type *__last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first,__last))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
|
||||
void insert(iterator __pos,
|
||||
const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
//Sequence requirements 23.1.1 Table 67:
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
void insert(iterator __pos,
|
||||
iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
//Sequence requirements 23.1.1 Table 67:
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
|
||||
size_type __old_capacity = capacity();
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
|
||||
_Compare_Capacity(__old_capacity);
|
||||
}
|
||||
#endif
|
||||
|
||||
void insert (iterator __pos, size_type __n, const _Tp& __x){
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Check_Overflow(__n);
|
||||
_M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
_STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
|
||||
_Invalidate_iterator(end());
|
||||
_M_non_dbg_impl.pop_back();
|
||||
}
|
||||
iterator erase(iterator __pos) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
|
||||
_Invalidate_iterators(__pos, end());
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
|
||||
}
|
||||
iterator erase(iterator __first, iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
|
||||
_Invalidate_iterators(__first, end());
|
||||
return iterator(&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
|
||||
}
|
||||
|
||||
#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size, const _Tp& __x = _STLP_DEFAULT_CONSTRUCTED(_Tp)) {
|
||||
#else
|
||||
void resize(size_type __new_size, const _Tp& __x) {
|
||||
#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
|
||||
if (__new_size > capacity()) {
|
||||
_Invalidate_all();
|
||||
}
|
||||
else if (__new_size < size()) {
|
||||
_Invalidate_iterators(begin() + __new_size, end());
|
||||
}
|
||||
_M_non_dbg_impl.resize(__new_size, __x);
|
||||
}
|
||||
|
||||
#if defined (_STLP_DONT_SUP_DFLT_PARAM)
|
||||
void resize(size_type __new_size) { resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
|
||||
#endif
|
||||
|
||||
#if defined (_STLP_MEMBER_TEMPLATES)
|
||||
template <class _InputIterator>
|
||||
void assign(_InputIterator __first, _InputIterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
|
||||
}
|
||||
#else
|
||||
private:
|
||||
void _M_assign(const value_type *__first, const value_type *__last) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__first, __last);
|
||||
}
|
||||
public:
|
||||
void assign(const value_type *__first, const value_type *__last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first,__last))
|
||||
_M_assign(__first, __last);
|
||||
}
|
||||
|
||||
void assign(const_iterator __first, const_iterator __last) {
|
||||
_STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first,__last))
|
||||
_M_assign(__first._M_iterator, __last._M_iterator);
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
void assign(size_type __n, const _Tp& __val) {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.assign(__n, __val);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_Invalidate_all();
|
||||
_M_non_dbg_impl.clear();
|
||||
}
|
||||
void push_back(const _Tp& __x) {
|
||||
_Check_Overflow(1);
|
||||
_M_non_dbg_impl.push_back(__x);
|
||||
}
|
||||
};
|
||||
|
||||
_STLP_END_NAMESPACE
|
||||
|
||||
#undef _STLP_NON_DBG_VECTOR
|
||||
|
||||
#endif /* _STLP_DBG_VECTOR_H */
|
||||
|
||||
// Local Variables:
|
||||
// mode:C++
|
||||
// End:
|
||||
Reference in New Issue
Block a user