23#if (defined (_STLP_DEBUG) || defined (_STLP_DEBUG_ALLOC)) && \
24 !defined (_STLP_ASSERTIONS)
25# define _STLP_ASSERTIONS 1
28#if defined (_STLP_ASSERTIONS)
30# if !defined (_STLP_FILE__)
31# define _STLP_FILE__ __FILE__
40 _StlFormat_ERROR_RETURN,
41 _StlFormat_ASSERTION_FAILURE,
42 _StlFormat_VERBOSE_ASSERTION_FAILURE,
43 _StlMsg_INVALID_ARGUMENT,
45 _StlMsg_INVALID_CONTAINER,
46 _StlMsg_EMPTY_CONTAINER,
47 _StlMsg_ERASE_PAST_THE_END,
48 _StlMsg_OUT_OF_BOUNDS,
50 _StlMsg_SHOULD_NOT_OWNER,
51 _StlMsg_INVALID_ITERATOR,
52 _StlMsg_INVALID_LEFTHAND_ITERATOR,
53 _StlMsg_INVALID_RIGHTHAND_ITERATOR,
54 _StlMsg_DIFFERENT_OWNERS ,
55 _StlMsg_NOT_DEREFERENCEABLE ,
56 _StlMsg_INVALID_RANGE ,
57 _StlMsg_NOT_IN_RANGE_1 ,
58 _StlMsg_NOT_IN_RANGE_2 ,
59 _StlMsg_INVALID_ADVANCE ,
60 _StlMsg_SINGULAR_ITERATOR ,
62 _StlMsg_INVALID_STRICT_WEAK_PREDICATE,
63 _StlMsg_INVALID_EQUIVALENT_PREDICATE,
65 _StlMsg_DBA_DELETED_TWICE ,
66 _StlMsg_DBA_NEVER_ALLOCATED ,
67 _StlMsg_DBA_TYPE_MISMATCH ,
68 _StlMsg_DBA_SIZE_MISMATCH ,
69 _StlMsg_DBA_UNDERRUN ,
72 _StlMsg_AUTO_PTR_NULL ,
74 _StlMsg_WRONG_MEMORY_ALIGNMENT,
80# define _StlMsg_MAX 31
85# if defined (_STLP_DEBUG_MODE_THROWS)
86# define _STLP_MESSAGE_NORETURN _STLP_FUNCTION_THROWS
88# define _STLP_MESSAGE_NORETURN
91template <
class _Dummy>
92class __stl_debug_engine {
96 static void _STLP_MESSAGE_NORETURN
_STLP_CALL _Message(
const char * format_str, ...);
99 static void _STLP_CALL _IndexedError(
int __ind,
const char* __f,
int __l);
104 static void _STLP_CALL _Assert(
const char* __expr,
const char* __f,
int __l);
107 static void _STLP_CALL _VerboseAssert(
const char* __expr,
int __error_ind,
const char* __f,
int __l);
114# if defined (_STLP_DEBUG)
117 static bool _STLP_CALL _Check_same_owner(
const __owned_link& __i1,
118 const __owned_link& __i2);
119 static bool _STLP_CALL _Check_same_or_null_owner(
const __owned_link& __i1,
120 const __owned_link& __i2);
121 static bool _STLP_CALL _Check_if_owner(
const __owned_list*,
const __owned_link&);
123 static bool _STLP_CALL _Check_if_not_owner(
const __owned_list*,
const __owned_link&);
125 static void _STLP_CALL _Verify(
const __owned_list*);
127 static void _STLP_CALL _Swap_owners(__owned_list&, __owned_list&);
129 static void _STLP_CALL _Invalidate_all(__owned_list*);
131 static void _STLP_CALL _Set_owner(__owned_list& , __owned_list& );
133 static void _STLP_CALL _Stamp_all(__owned_list*, __owned_list*);
135 static void _STLP_CALL _M_detach(__owned_list*, __owned_link*);
137 static void _STLP_CALL _M_attach(__owned_list*, __owned_link*);
140 static void*
_STLP_CALL _Get_container_ptr(
const __owned_link*);
144 static const char* _Message_table[_StlMsg_MAX];
147# undef _STLP_MESSAGE_NORETURN
149# if defined (_STLP_USE_TEMPLATE_EXPORT)
153typedef __stl_debug_engine<bool> __stl_debugger;
159# if !defined (_STLP_ASSERT)
160# define _STLP_ASSERT(expr) \
161 if (!(expr)) { _STLP_PRIV __stl_debugger::_Assert( # expr, _STLP_FILE__, __LINE__); }
165# define _STLP_ASSERT(expr)
169#if defined (_STLP_DEBUG)
171# if !defined (_STLP_VERBOSE_ASSERT)
173# define _STLP_VERBOSE_ASSERT(expr, __diag_num) \
174 if (!(expr)) { _STLP_PRIV __stl_debugger::_VerboseAssert\
175 ( # expr, _STLP_PRIV __diag_num, _STLP_FILE__, __LINE__ ); \
179# define _STLP_DEBUG_CHECK(expr) _STLP_ASSERT(expr)
181# if (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
182# define _STLP_STD_DEBUG_CHECK(expr) _STLP_DEBUG_CHECK(expr)
184# define _STLP_STD_DEBUG_CHECK(expr)
187# if !defined (_STLP_VERBOSE_RETURN)
188# define _STLP_VERBOSE_RETURN(__expr,__diag_num) if (!(__expr)) { \
189 _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__ , __LINE__); \
193# if !defined (_STLP_VERBOSE_RETURN_0)
194# define _STLP_VERBOSE_RETURN_0(__expr,__diag_num) if (!(__expr)) { \
195 _STLP_PRIV __stl_debugger::_IndexedError(__diag_num, _STLP_FILE__, __LINE__); \
199# ifndef _STLP_INTERNAL_THREADS_H
203# ifndef _STLP_INTERNAL_ITERATOR_BASE_H
207# ifndef _STLP_TYPE_TRAITS_H
220template <
class _Traits>
221struct _DbgTraits : _Traits {
222 typedef _DbgTraits<typename _Traits::_ConstTraits> _ConstTraits;
223 typedef _DbgTraits<typename _Traits::_NonConstTraits> _NonConstTraits;
225 template <
class _Iterator>
226 static bool _Check(
const _Iterator&) {
return true;}
230template <
class _Iterator>
231inline bool _STLP_CALL __valid_range(
const _Iterator& __i1 ,
const _Iterator& __i2,
233{
return (__i1 < __i2) || (__i1 == __i2); }
235template <
class _Iterator>
236inline bool _STLP_CALL __valid_range(
const _Iterator& __i1 ,
const _Iterator& __i2,
239 bool __dummy(__i1==__i2);
240 return (__dummy==__dummy);
243template <
class _Iterator>
244inline bool _STLP_CALL __valid_range(
const _Iterator& __i1 ,
const _Iterator& __i2,
247 bool __dummy(__i1==__i2);
248 return (__dummy==__dummy);
251template <
class _Iterator>
252inline bool _STLP_CALL __valid_range(
const _Iterator&,
const _Iterator&,
256template <
class _Iterator>
257inline bool _STLP_CALL __valid_range(
const _Iterator&,
const _Iterator&,
261template <
class _Iterator>
262inline bool _STLP_CALL __valid_range(
const _Iterator& __i1,
const _Iterator& __i2)
266template <
class _Iterator>
267inline bool _STLP_CALL stlp_in_range(
const _Iterator& _It,
268 const _Iterator& __i1,
const _Iterator& __i2)
269{
return __valid_range(__i1,_It) && __valid_range(_It,__i2); }
271template <
class _Iterator>
272inline bool _STLP_CALL stlp_in_range(
const _Iterator& __first,
const _Iterator&
__last,
273 const _Iterator& __start,
const _Iterator& __finish)
274{
return __valid_range(__first,
__last) && __valid_range(__start,__first) && __valid_range(
__last,__finish); }
285#if defined(_STLP_WCE) && defined(_ARM_)
286 __owned_link() : _M_self(this), _M_owner(0) {}
287 __owned_link(
const __owned_list*
__c) : _M_self(this), _M_owner(0), _M_next(0)
289 __owned_link(
const __owned_link& __rhs): _M_self(this), _M_owner(0)
290 { __stl_debugger::_M_attach(
__CONST_CAST(__owned_list*,__rhs._M_owner),
this); }
292 __owned_link() : _M_owner(0) {}
293 __owned_link(
const __owned_list*
__c) : _M_owner(0), _M_next(0)
295 __owned_link(
const __owned_link& __rhs): _M_owner(0)
296 { __stl_debugger::_M_attach(
__CONST_CAST(__owned_list*,__rhs._M_owner),
this); }
298 __owned_link& operator=(
const __owned_link& __rhs) {
299 __owned_list* __new_owner =
__CONST_CAST(__owned_list*,__rhs._M_owner);
300 __owned_list* __old_owner = _M_owner;
301 if ( __old_owner != __new_owner ) {
302 __stl_debugger::_M_detach(__old_owner,
this);
303 __stl_debugger::_M_attach(__new_owner,
this);
307#if defined(_STLP_WCE) && defined(_ARM_)
309 __stl_debugger::_M_detach(_M_owner, _M_self);
314 __stl_debugger::_M_detach(_M_owner,
this);
319 const __owned_list* _Owner()
const {
return _M_owner; }
320 __owned_list* _Owner() {
return _M_owner; }
321 void _Set_owner(
const __owned_list* __o) { _M_owner=
__CONST_CAST(__owned_list*,__o); }
322 bool _Valid()
const {
return _M_owner != 0; }
323 void _Invalidate() { _M_owner = 0; _M_next = 0; }
324 void _Link_to_self() { _M_next = 0; }
326 __owned_link* _Next() {
return _M_next; }
327 const __owned_link* _Next()
const {
return _M_next; }
330#if defined(_STLP_WCE) && defined(_ARM_)
331 __owned_link* _M_self;
334 __owned_list* _M_owner;
335 __owned_link* _M_next;
341 __owned_list(
void* __o) {
350 _M_node._Invalidate();
352 const void* _Owner()
const {
return (
const void*)_M_node._M_owner; }
353 void* _Owner() {
return (
void*)_M_node._M_owner; }
354 bool _Valid()
const {
return _M_node._M_owner != 0; }
355 void _Invalidate() { _M_node._M_owner = 0; }
357 __owned_link* _First() {
return _M_node._Next(); }
358 __owned_link* _Last() {
return 0 ; }
360 const __owned_link* _First()
const {
return (__owned_link*)_M_node._M_next; }
361 const __owned_link* _Last()
const {
return 0 ;}
363 void _Verify()
const { __stl_debugger::_Verify(
this); }
364 void _Swap_owners(__owned_list& __y) { __stl_debugger::_Swap_owners(*
this, __y); }
365 void _Invalidate_all() { __stl_debugger::_Invalidate_all(
this); }
366 void _Set_owner(__owned_list& __y) { __stl_debugger::_Set_owner(*
this, __y); }
368 mutable __owned_link _M_node;
374 __owned_list(
const __owned_list&){}
375 __owned_list& operator = (
const __owned_list&) {
return *
this; }
377 friend class __owned_link;
378 friend class __stl_debug_engine<
bool>;
386template <
class _Iterator>
387bool _STLP_CALL __check_range(
const _Iterator&,
const _Iterator&);
388template <
class _Iterator>
389bool _STLP_CALL __check_range(
const _Iterator&,
390 const _Iterator&,
const _Iterator&);
391template <
class _Iterator>
392bool _STLP_CALL __check_range(
const _Iterator&,
const _Iterator& ,
393 const _Iterator&,
const _Iterator& );
395bool _STLP_CALL __check_ptr_range(
const _Tp*,
const _Tp*);
397template <
class _Iterator>
398void _STLP_CALL __invalidate_range(
const __owned_list* __base,
399 const _Iterator& __first,
402template <
class _Iterator>
403void _STLP_CALL __invalidate_iterator(
const __owned_list* __base,
404 const _Iterator&
__it);
406template <
class _Iterator>
407void _STLP_CALL __change_range_owner(
const _Iterator& __first,
409 const __owned_list* __dst);
411template <
class _Iterator>
413 const __owned_list* __dst);
417__check_same_owner(
const __owned_link& __i1,
const __owned_link& __i2)
418{
return __stl_debugger::_Check_same_owner(__i1,__i2); }
421__check_same_or_null_owner(
const __owned_link& __i1,
const __owned_link& __i2)
422{
return __stl_debugger::_Check_same_or_null_owner(__i1,__i2); }
424template <
class _Iterator>
425inline bool _STLP_CALL __check_if_owner(
const __owned_list* __owner,
426 const _Iterator&
__it)
427{
return __stl_debugger::_Check_if_owner(__owner, (
const __owned_link&)
__it); }
429template <
class _Iterator>
430inline bool _STLP_CALL __check_if_not_owner(
const __owned_list* __owner,
431 const _Iterator&
__it)
432{
return __stl_debugger::_Check_if_not_owner(__owner, (
const __owned_link&)
__it); }
439# define _STLP_VERBOSE_ASSERT(expr, diagnostic)
440# define _STLP_DEBUG_CHECK(expr)
443#if defined (_STLP_ASSERTIONS)
445# if !defined (_STLP_ASSERT_MSG_TRAILER)
446# define _STLP_ASSERT_MSG_TRAILER
450# if !defined (_STLP_DEBUG_MESSAGE)
451# define __stl_debug_message __stl_debugger::_Message
453extern void __stl_debug_message(
const char * format_str, ...);
457# if !defined (_STLP_DEBUG_TERMINATE)
458# define __stl_debug_terminate __stl_debugger::_Terminate
460extern void __stl_debug_terminate();
465#if defined (_STLP_ASSERTIONS) && !defined (_STLP_LINK_TIME_INSTANTIATION)
_STLP_INLINE_LOOP _InputIter __last
#define _STLP_ITERATOR_CATEGORY(_It, _Tp)
_STLP_MOVE_TO_PRIV_NAMESPACE const _InputIterator const input_iterator_tag &_InputIterator __it(__first)
#define __REINTERPRET_CAST(__x, __y)
#define _STLP_MOVE_TO_STD_NAMESPACE
#define __CONST_CAST(__x, __y)
#define _STLP_CLASS_DECLSPEC
#define _STLP_EXPORT_TEMPLATE_CLASS
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
#define _STLP_MOVE_TO_PRIV_NAMESPACE