Remove _LIBCPP_DEBUG. This was my first attempt at debug mode for libc++, and is now obsoleted by _LIBCPP_DEBUG2 (which isn't finished).

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@189135 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2013-08-23 19:03:36 +00:00
parent 499cea12bb
commit 5d5f9f9786
2 changed files with 0 additions and 450 deletions

View File

@@ -1371,422 +1371,6 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n,
return __x;
}
#ifdef _LIBCPP_DEBUG
// __debug_iter
template <class _Container, class _Iter> class __debug_iter;
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
bool
operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
typename __debug_iter<_Container, _Iter1>::difference_type
operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&);
template <class _Container, class _Iter>
_LIBCPP_INLINE_VISIBILITY
__debug_iter<_Container, _Iter>
operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&);
template <class _Container, class _Iter>
class __debug_iter
{
public:
typedef _Iter iterator_type;
typedef _Container __container_type;
typedef typename iterator_traits<iterator_type>::iterator_category iterator_category;
typedef typename iterator_traits<iterator_type>::value_type value_type;
typedef typename iterator_traits<iterator_type>::difference_type difference_type;
typedef typename iterator_traits<iterator_type>::pointer pointer;
typedef typename iterator_traits<iterator_type>::reference reference;
private:
iterator_type __i;
__debug_iter* __next;
__container_type* __cont;
public:
_LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {}
_LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x)
: __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);}
__debug_iter& operator=(const __debug_iter& __x);
template <class _Up> _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u,
typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0)
: __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);}
_LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();}
_LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;}
_LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());}
_LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;}
_LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int)
{__debug_iter __tmp(*this); operator++(); return __tmp;}
_LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;}
_LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int)
{__debug_iter __tmp(*this); operator--(); return __tmp;}
_LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const
{__debug_iter __t(*this); __t += __n; return __t;}
__debug_iter& operator+=(difference_type __n);
_LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const
{__debug_iter __t(*this); __t -= __n; return __t;}
_LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n)
{*this += -__n; return *this;}
_LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const
{return *(*this + __n);}
private:
_LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x)
: __i(__x), __next(0), __cont(0) {__set_owner(__c);}
_LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;}
void __set_owner(const __container_type* __c);
void __remove_owner();
static void __remove_all(__container_type* __c);
static void swap(__container_type* __x, __container_type* __y);
_LIBCPP_INLINE_VISIBILITY bool __is_deref() const
{return __is_deref(__is_random_access_iterator<iterator_type>());}
bool __is_deref(false_type) const;
bool __is_deref(true_type) const;
_LIBCPP_INLINE_VISIBILITY bool __can_decrement() const
{return __can_decrement(integral_constant<int, is_pointer<iterator_type>::value ? 2:
__is_random_access_iterator<iterator_type>::value ? 1 : 0>());}
bool __can_decrement(integral_constant<int, 0>) const;
bool __can_decrement(integral_constant<int, 1>) const;
bool __can_decrement(integral_constant<int, 2>) const;
_LIBCPP_INLINE_VISIBILITY bool __can_increment() const
{return __can_increment(integral_constant<int, is_pointer<iterator_type>::value ? 2:
__is_random_access_iterator<iterator_type>::value ? 1 : 0>());}
bool __can_increment(integral_constant<int, 0>) const;
bool __can_increment(integral_constant<int, 1>) const;
bool __can_increment(integral_constant<int, 2>) const;
_LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const
{return __can_add(__n, is_pointer<iterator_type>());}
bool __can_add(difference_type __n, false_type) const;
bool __can_add(difference_type __n, true_type) const;
template <class _Cp, class _Up> friend class __debug_iter;
friend class _Container::__self;
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
bool
operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1, class _Iter2>
friend
typename __debug_iter<_Cp, _Iter1>::difference_type
operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&);
template <class _Cp, class _Iter1>
friend
__debug_iter<_Cp, _Iter1>
operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&);
};
template <class _Container, class _Iter>
__debug_iter<_Container, _Iter>&
__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x)
{
if (this != &__x)
{
__remove_owner();
__i = __x.__i;
__set_owner(__x.__cont);
}
return *this;
}
template <class _Container, class _Iter>
void
__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c)
{
__cont = const_cast<__container_type*>(__c);
__debug_iter*& __head = __cont->__get_iterator_list(this);
__next = __head;
__head = this;
}
template <class _Container, class _Iter>
void
__debug_iter<_Container, _Iter>::__remove_owner()
{
if (__cont)
{
__debug_iter*& __head = __cont->__get_iterator_list(this);
if (__head == this)
__head = __next;
else
{
__debug_iter* __prev = __head;
for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next)
__prev = __p;
__prev->__next = __next;
}
__cont = 0;
}
}
template <class _Container, class _Iter>
void
__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c)
{
__debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0);
__debug_iter* __p = __head;
__head = 0;
while (__p)
{
__p->__cont = 0;
__debug_iter* __n = __p->__next;
__p->__next = 0;
__p = __n;
}
}
template <class _Container, class _Iter>
void
__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y)
{
__debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0);
__debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0);
__debug_iter* __p = __head_x;
__head_x = __head_y;
__head_y = __p;
for (__p = __head_x; __p; __p = __p->__next)
__p->__cont = __x;
for (__p = __head_y; __p; __p = __p->__next)
__p->__cont = __y;
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__is_deref(false_type) const
{
if (__cont == 0)
return false;
return __i != __cont->end().base();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__is_deref(true_type) const
{
if (__cont == 0)
return false;
return __i < __cont->end().base();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 0>) const
{
if (__cont == 0)
return false;
return __i != __cont->begin().base();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 1>) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
return __b < __i && __i <= __b + __cont->size();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 2>) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
return __b < __i && __i <= __b + __cont->size();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 0>) const
{
if (__cont == 0)
return false;
return __i != __cont->end().base();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 1>) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
return __b <= __i && __i < __b + __cont->size();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 2>) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
return __b <= __i && __i < __b + __cont->size();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
iterator_type __j = __i + __n;
return __b <= __j && __j <= __b + __cont->size();
}
template <class _Container, class _Iter>
bool
__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const
{
if (__cont == 0)
return false;
iterator_type __b = __cont->begin().base();
iterator_type __j = __i + __n;
return __b <= __j && __j <= __b + __cont->size();
}
template <class _Container, class _Iter>
__debug_iter<_Container, _Iter>&
__debug_iter<_Container, _Iter>::operator+=(difference_type __n)
{
assert(__can_add(__n));
__i += __n;
return *this;
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
assert(__x.__cont && __x.__cont == __y.__cont);
return __x.base() == __y.base();
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
return !(__x == __y);
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
assert(__x.__cont && __x.__cont == __y.__cont);
return __x.base() < __y.base();
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
return __y < __x;
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
return !(__x < __y);
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
bool
operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
return !(__y < __x);
}
template <class _Container, class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY
typename __debug_iter<_Container, _Iter1>::difference_type
operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y)
{
assert(__x.__cont && __x.__cont == __y.__cont);
return __x.base() - __y.base();
}
template <class _Container, class _Iter>
inline _LIBCPP_INLINE_VISIBILITY
__debug_iter<_Container, _Iter>
operator+(typename __debug_iter<_Container, _Iter>::difference_type __n,
const __debug_iter<_Container, _Iter>& __x)
{
return __x + __n;
}
#endif // _LIBCPP_DEBUG
#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN)
template <class _Cp>