⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _debug.h

📁 A port of the original STL to many platforms.可以配合多种编译器使用,特别是在使用intel编译器时可以很好的优化代码性能.
💻 H
📖 第 1 页 / 共 2 页
字号:
  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 __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 __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:
  __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); }
  __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;
  }
  ~__owned_link() {
    __stl_debugger::_M_detach(_M_owner, this);
    _Invalidate();
  }

  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:
  __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 struct __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*/,
                                             const __false_type&)
{ return true; }

template <class _Iterator>
inline bool _STLP_CALL __check_if_not_owner( const __owned_list* __owner,
                                             const _Iterator& __it,
                                             const __true_type&)
{ return __stl_debugger::_Check_if_not_owner(__owner, (const __owned_link&)__it); }

_STLP_MOVE_TO_STD_NAMESPACE

_STLP_END_NAMESPACE

#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_LINK_TIME_INSTANTIATION)
#  include <stl/debug/_debug.c>
#endif

#endif /* DEBUG_H */

// Local Variables:
// mode:C++
// End:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -